comparison 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
comparison
equal deleted inserted replaced
0:a06113de4d67 1:caeb520cebed
42 #include "ggc.h" 42 #include "ggc.h"
43 #include "target.h" 43 #include "target.h"
44 #include "tree-iterator.h" 44 #include "tree-iterator.h"
45 #include "gimple.h" 45 #include "gimple.h"
46 #include "tree-flow.h" 46 #include "tree-flow.h"
47 #ifndef noCbC
48 #include "cbc-tree.h"
49 #endif
47 50
48 /* Possible cases of implicit bad conversions. Used to select 51 /* Possible cases of implicit bad conversions. Used to select
49 diagnostic messages in convert_for_assignment. */ 52 diagnostic messages in convert_for_assignment. */
50 enum impl_conv { 53 enum impl_conv {
51 ic_argpass, 54 ic_argpass,
401 404
402 case FUNCTION_TYPE: 405 case FUNCTION_TYPE:
403 /* Function types: prefer the one that specified arg types. 406 /* Function types: prefer the one that specified arg types.
404 If both do, merge the arg types. Also merge the return types. */ 407 If both do, merge the arg types. Also merge the return types. */
405 { 408 {
409 #ifndef noCbC
410 int is_code_segment = CbC_IS_CODE_SEGMENT(t1);
411 #endif
406 tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2)); 412 tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2));
407 tree p1 = TYPE_ARG_TYPES (t1); 413 tree p1 = TYPE_ARG_TYPES (t1);
408 tree p2 = TYPE_ARG_TYPES (t2); 414 tree p2 = TYPE_ARG_TYPES (t2);
409 int len; 415 int len;
410 tree newargs, n; 416 tree newargs, n;
417 return build_type_attribute_variant (t2, attributes); 423 return build_type_attribute_variant (t2, attributes);
418 424
419 /* Simple way if one arg fails to specify argument types. */ 425 /* Simple way if one arg fails to specify argument types. */
420 if (TYPE_ARG_TYPES (t1) == 0) 426 if (TYPE_ARG_TYPES (t1) == 0)
421 { 427 {
428 #ifndef noCbC
429 if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t2));
430 else
431 #endif
422 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2)); 432 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2));
423 t1 = build_type_attribute_variant (t1, attributes); 433 t1 = build_type_attribute_variant (t1, attributes);
424 return qualify_type (t1, t2); 434 return qualify_type (t1, t2);
425 } 435 }
426 if (TYPE_ARG_TYPES (t2) == 0) 436 if (TYPE_ARG_TYPES (t2) == 0)
427 { 437 {
438 #ifndef noCbC
439 if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t1));
440 else
441 #endif
428 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1)); 442 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1));
429 t1 = build_type_attribute_variant (t1, attributes); 443 t1 = build_type_attribute_variant (t1, attributes);
430 return qualify_type (t1, t2); 444 return qualify_type (t1, t2);
431 } 445 }
432 446
516 TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2)); 530 TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2));
517 parm_done: ; 531 parm_done: ;
518 } 532 }
519 533
520 c_override_global_bindings_to_false = false; 534 c_override_global_bindings_to_false = false;
535
536 #ifndef noCbC
537 if (is_code_segment) t1 = build_code_segment_type (valtype, newargs);
538 else
539 #endif
521 t1 = build_function_type (valtype, newargs); 540 t1 = build_function_type (valtype, newargs);
522 t1 = qualify_type (t1, t2); 541 t1 = qualify_type (t1, t2);
523 /* ... falls through ... */ 542 /* ... falls through ... */
524 } 543 }
525 544
2197 2216
2198 if (decl && decl != error_mark_node) 2217 if (decl && decl != error_mark_node)
2199 ref = decl; 2218 ref = decl;
2200 else if (fun) 2219 else if (fun)
2201 /* Implicit function declaration. */ 2220 /* Implicit function declaration. */
2221 #ifndef noCbC
2222 ref = implicitly_declare (id, fun);
2223 #else
2202 ref = implicitly_declare (id); 2224 ref = implicitly_declare (id);
2225 #endif
2203 else if (decl == error_mark_node) 2226 else if (decl == error_mark_node)
2204 /* Don't complain about something that's already been 2227 /* Don't complain about something that's already been
2205 complained about. */ 2228 complained about. */
2206 return error_mark_node; 2229 return error_mark_node;
2207 else 2230 else
2741 typetail = TREE_CHAIN (typetail); 2764 typetail = TREE_CHAIN (typetail);
2742 } 2765 }
2743 2766
2744 gcc_assert (parmnum == nargs); 2767 gcc_assert (parmnum == nargs);
2745 2768
2769 #ifndef noCbC
2770 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node
2771 //&& !CbC_IS_CODE_SEGMENT(TREE_TYPE(fundecl)) )
2772 && !(fundecl&&CbC_IS_CODE_SEGMENT(fundecl)) )
2773 #else
2746 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) 2774 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
2775 #endif
2747 { 2776 {
2748 error ("too few arguments to function %qE", function); 2777 error ("too few arguments to function %qE", function);
2749 return -1; 2778 return -1;
2750 } 2779 }
2751 2780