changeset 105:b3cfc7733d3f

fix bug. implementation fo rectype. c-family/c-pretty-print.c
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Fri, 25 May 2012 10:34:23 +0900
parents 46ee985e4f0e
children 85047c4f1ca4
files CbC-examples/rectypeTest/rectypeTest1.c gcc/c-family/c-pretty-print.c gcc/c-parser.c
diffstat 3 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/rectypeTest/rectypeTest1.c	Fri May 25 10:34:23 2012 +0900
@@ -0,0 +1,22 @@
+#include <stdio.h>
+__code print(__rectype *p, int num) {
+  printf("num = %d\n",num);
+}
+
+__code csA(__rectype *p, int num) {
+  goto p(csA,3,4);
+  goto p(2,3);
+  goto p(csA,3);
+  return;
+}
+
+void funcA(__code (*p)()){
+  goto p(print, 3);
+  return;
+}
+
+int main() {
+  funcA(csA);
+
+  return 0;
+}
--- a/gcc/c-family/c-pretty-print.c	Mon Apr 09 19:01:21 2012 +0900
+++ b/gcc/c-family/c-pretty-print.c	Fri May 25 10:34:23 2012 +0900
@@ -29,7 +29,9 @@
 #include "tree-pretty-print.h"
 #include "tree-iterator.h"
 #include "diagnostic.h"
-
+#ifndef noCbC
+#include "cbc-tree.h"
+#endif
 /* Translate if being used for diagnostics, but not for dump files or
    __PRETTY_FUNCTION.  */
 #define M_(msgid) (pp_translate_identifiers (pp) ? _(msgid) : (msgid))
@@ -544,6 +546,9 @@
       if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
 	  || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
 	pp_c_right_paren (pp);
+#ifndef noCbC
+      if(IS_RECTYPE(t)) return;
+#endif
       t = TREE_TYPE (t);
     }
 
--- a/gcc/c-parser.c	Mon Apr 09 19:01:21 2012 +0900
+++ b/gcc/c-parser.c	Fri May 25 10:34:23 2012 +0900
@@ -1638,7 +1638,7 @@
 				   chainon (postfix_attrs,
 					    all_prefix_attrs));
 #ifndef noCbC
-	      if(specs->typespec_word == cts_CbC_code ) {
+	      if (specs->typespec_word == cts_CbC_code) {
 		/* 
 		 * func_tree is TYPE_DECL or FUNCTION_DECL.
 		 * tmp is POINTER_TYPE or FUNCTION_TYPE.
@@ -1655,12 +1655,21 @@
 		  tree t = TREE_TYPE(tmptype);
 		  while (TREE_CODE(t) == POINTER_TYPE) {
 		    tmptype = t;
-		    t= TREE_TYPE(tmptype);
+		    t = TREE_TYPE(tmptype);
 		  }
 		  TREE_TYPE(tmptype) = func_tree;
 		  parm = TREE_CHAIN(parm);
 		}
 	      }
+	      if (specs->typespec_word == cts_CbC_rec) {
+		tree t = TREE_TYPE(d);
+		tree tmptype = t;
+		while (TREE_CODE(t) == POINTER_TYPE) {
+		  tmptype = t;
+		  t = TREE_TYPE(tmptype);
+		}
+		TREE_TYPE(tmptype) = TREE_TYPE(current_function_decl);
+	      }
 
 #endif
 	      if (d)
@@ -2146,9 +2155,9 @@
 	    /*attrs = build_tree_list (get_identifier("noreturn"), attrs);*/
 	    declspecs_add_attrs(specs, attrs);
       }
-	  
-	  c_parser_consume_token (parser);
-	  break;
+
+          c_parser_consume_token (parser);
+          break;
 	case RID_CbC_SELFTYPE:
 	  if (!typespec_ok)
 	    goto out;