diff gcc/c-typeck.c @ 1:caeb520cebed

patch for CbC
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2009 17:43:54 +0900
parents a06113de4d67
children 27e6f95b2c21
line wrap: on
line diff
--- a/gcc/c-typeck.c	Fri Jul 17 14:47:48 2009 +0900
+++ b/gcc/c-typeck.c	Fri Jul 17 17:43:54 2009 +0900
@@ -44,6 +44,9 @@
 #include "tree-iterator.h"
 #include "gimple.h"
 #include "tree-flow.h"
+#ifndef noCbC
+  #include "cbc-tree.h"
+#endif
 
 /* Possible cases of implicit bad conversions.  Used to select
    diagnostic messages in convert_for_assignment.  */
@@ -403,6 +406,9 @@
       /* Function types: prefer the one that specified arg types.
 	 If both do, merge the arg types.  Also merge the return types.  */
       {
+#ifndef noCbC
+	int is_code_segment = CbC_IS_CODE_SEGMENT(t1);
+#endif
 	tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2));
 	tree p1 = TYPE_ARG_TYPES (t1);
 	tree p2 = TYPE_ARG_TYPES (t2);
@@ -419,12 +425,20 @@
 	/* Simple way if one arg fails to specify argument types.  */
 	if (TYPE_ARG_TYPES (t1) == 0)
 	 {
+#ifndef noCbC
+	   if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t2));
+	   else
+#endif
 	    t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2));
 	    t1 = build_type_attribute_variant (t1, attributes);
 	    return qualify_type (t1, t2);
 	 }
 	if (TYPE_ARG_TYPES (t2) == 0)
 	 {
+#ifndef noCbC
+	   if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t1));
+	   else
+#endif
 	   t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1));
 	   t1 = build_type_attribute_variant (t1, attributes);
 	   return qualify_type (t1, t2);
@@ -518,6 +532,11 @@
 	  }
 
 	c_override_global_bindings_to_false = false;
+
+#ifndef noCbC
+	if (is_code_segment) t1 = build_code_segment_type (valtype, newargs);
+	else
+#endif
 	t1 = build_function_type (valtype, newargs);
 	t1 = qualify_type (t1, t2);
 	/* ... falls through ...  */
@@ -2199,7 +2218,11 @@
     ref = decl;
   else if (fun)
     /* Implicit function declaration.  */
+#ifndef noCbC
+    ref = implicitly_declare (id, fun);
+#else
     ref = implicitly_declare (id);
+#endif
   else if (decl == error_mark_node)
     /* Don't complain about something that's already been
        complained about.  */
@@ -2743,7 +2766,13 @@
 
   gcc_assert (parmnum == nargs);
 
+#ifndef noCbC
+  if (typetail != 0 && TREE_VALUE (typetail) != void_type_node
+	  //&& !CbC_IS_CODE_SEGMENT(TREE_TYPE(fundecl)) )
+	  && !(fundecl&&CbC_IS_CODE_SEGMENT(fundecl)) )
+#else
   if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
+#endif
     {
       error ("too few arguments to function %qE", function);
       return -1;