diff gcc/c/c-typeck.c @ 112:ab0bcb71f44d

merge gcc 7
author mir3636
date Fri, 10 Nov 2017 19:46:38 +0900
parents 04ced10e8804
children bdf41c9fa0b7
line wrap: on
line diff
--- a/gcc/c/c-typeck.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/c/c-typeck.c	Fri Nov 10 19:46:38 2017 +0900
@@ -53,6 +53,9 @@
 #include "stringpool.h"
 #include "attribs.h"
 #include "asan.h"
+#ifndef noCbC
+  #include "cbc-tree.h"
+#endif
 
 /* Possible cases of implicit bad conversions.  Used to select
    diagnostic messages in convert_for_assignment.  */
@@ -495,6 +498,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);
@@ -511,12 +517,20 @@
 	/* Simple way if one arg fails to specify argument types.  */
 	if (TYPE_ARG_TYPES (t1) == NULL_TREE)
 	 {
+#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) == NULL_TREE)
 	 {
+#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);
@@ -608,6 +622,11 @@
 	  parm_done: ;
 	  }
 
+#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);
       }
@@ -2757,7 +2776,11 @@
     }
   else if (fun)
     /* Implicit function declaration.  */
+#ifndef noCbC
+    ref = implicitly_declare (loc, id, fun);
+#else
     ref = implicitly_declare (loc, id);
+#endif
   else if (decl == error_mark_node)
     /* Don't complain about something that's already been
        complained about.  */
@@ -3560,8 +3583,13 @@
     }
 
   gcc_assert (parmnum == vec_safe_length (values));
-
-  if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node)
+fndef 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_at (loc, "too few arguments to function %qE", function);
       inform_declaration (fundecl);