diff CbC-examples/test_nest.c @ 16:4c6926a2b9bc

examples.
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Thu, 24 Sep 2009 12:51:25 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/test_nest.c	Thu Sep 24 12:51:25 2009 +0900
@@ -0,0 +1,50 @@
+
+int printf(char *, ...);
+typedef void (*RET_FUNC)(int, void *);
+
+void g(RET_FUNC func)
+{
+	func(33, 0);
+}
+
+int f()
+{
+	void *ret;
+	ret = ({
+		__label__ exit0;
+		int retval;
+		void __return_func(int retval_, void *fp){
+			retval = retval_;
+			goto exit0;
+		}
+		if (0) {
+		  exit0:
+			printf("f2: fp = 0x%x\n", __builtin_frame_address(0));
+			return retval;
+		}
+		__return_func;
+	});
+
+	//g(__return_func, __builtin_frame_address(0));
+	printf("f0: fp = 0x%x\n", __builtin_frame_address(0));
+	printf("__return_func = %x\n", ret);
+	g(ret);
+
+	printf("not good\n");
+	return 0;
+
+//exit0:
+	//printf("f2: fp = 0x%x\n", __builtin_frame_address(0));
+	//return retval;
+}
+
+int main(int argc, char **argv)
+{
+	int t;
+	printf("main before: fp = 0x%x\n", __builtin_frame_address(0));
+	t = f();
+	printf("f = %d\n", t);
+	printf("main after: fp = 0x%x\n", __builtin_frame_address(0));
+}
+
+