Mercurial > hg > CbC > CbC_gcc
comparison gcc/c-typeck.c @ 72:20c18990c3e4
merge gcc/c-typeck.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 22:22:32 +0900 |
parents | b81903832de2 |
children | 4a89a0a804df |
comparison
equal
deleted
inserted
replaced
71:e334828451cb | 72:20c18990c3e4 |
---|---|
39 #include "target.h" | 39 #include "target.h" |
40 #include "tree-iterator.h" | 40 #include "tree-iterator.h" |
41 #include "bitmap.h" | 41 #include "bitmap.h" |
42 #include "gimple.h" | 42 #include "gimple.h" |
43 #include "c-family/c-objc.h" | 43 #include "c-family/c-objc.h" |
44 #ifndef noCbC | |
45 #include "cbc-tree.h" | |
46 #endif | |
47 | |
44 | 48 |
45 /* Possible cases of implicit bad conversions. Used to select | 49 /* Possible cases of implicit bad conversions. Used to select |
46 diagnostic messages in convert_for_assignment. */ | 50 diagnostic messages in convert_for_assignment. */ |
47 enum impl_conv { | 51 enum impl_conv { |
48 ic_argpass, | 52 ic_argpass, |
476 | 480 |
477 case FUNCTION_TYPE: | 481 case FUNCTION_TYPE: |
478 /* Function types: prefer the one that specified arg types. | 482 /* Function types: prefer the one that specified arg types. |
479 If both do, merge the arg types. Also merge the return types. */ | 483 If both do, merge the arg types. Also merge the return types. */ |
480 { | 484 { |
485 #ifndef noCbC | |
486 int is_code_segment = CbC_IS_CODE_SEGMENT(t1); | |
487 #endif | |
481 tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2)); | 488 tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2)); |
482 tree p1 = TYPE_ARG_TYPES (t1); | 489 tree p1 = TYPE_ARG_TYPES (t1); |
483 tree p2 = TYPE_ARG_TYPES (t2); | 490 tree p2 = TYPE_ARG_TYPES (t2); |
484 int len; | 491 int len; |
485 tree newargs, n; | 492 tree newargs, n; |
492 return build_type_attribute_variant (t2, attributes); | 499 return build_type_attribute_variant (t2, attributes); |
493 | 500 |
494 /* Simple way if one arg fails to specify argument types. */ | 501 /* Simple way if one arg fails to specify argument types. */ |
495 if (TYPE_ARG_TYPES (t1) == 0) | 502 if (TYPE_ARG_TYPES (t1) == 0) |
496 { | 503 { |
504 #ifndef noCbC | |
505 if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t2)); | |
506 else | |
507 #endif | |
497 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2)); | 508 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2)); |
498 t1 = build_type_attribute_variant (t1, attributes); | 509 t1 = build_type_attribute_variant (t1, attributes); |
499 return qualify_type (t1, t2); | 510 return qualify_type (t1, t2); |
500 } | 511 } |
501 if (TYPE_ARG_TYPES (t2) == 0) | 512 if (TYPE_ARG_TYPES (t2) == 0) |
502 { | 513 { |
514 #ifndef noCbC | |
515 if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t1)); | |
516 else | |
517 #endif | |
503 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1)); | 518 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1)); |
504 t1 = build_type_attribute_variant (t1, attributes); | 519 t1 = build_type_attribute_variant (t1, attributes); |
505 return qualify_type (t1, t2); | 520 return qualify_type (t1, t2); |
506 } | 521 } |
507 | 522 |
591 TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2)); | 606 TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2)); |
592 parm_done: ; | 607 parm_done: ; |
593 } | 608 } |
594 | 609 |
595 c_override_global_bindings_to_false = false; | 610 c_override_global_bindings_to_false = false; |
611 #ifndef noCbC | |
612 if (is_code_segment) t1 = build_code_segment_type (valtype, newargs); | |
613 else | |
614 #endif | |
596 t1 = build_function_type (valtype, newargs); | 615 t1 = build_function_type (valtype, newargs); |
597 t1 = qualify_type (t1, t2); | 616 t1 = qualify_type (t1, t2); |
598 /* ... falls through ... */ | 617 /* ... falls through ... */ |
599 } | 618 } |
600 | 619 |
2456 ref = decl; | 2475 ref = decl; |
2457 *type = TREE_TYPE (ref); | 2476 *type = TREE_TYPE (ref); |
2458 } | 2477 } |
2459 else if (fun) | 2478 else if (fun) |
2460 /* Implicit function declaration. */ | 2479 /* Implicit function declaration. */ |
2480 #ifndef noCbC | |
2481 ref = implicitly_declare (loc, id, fun); | |
2482 #else | |
2461 ref = implicitly_declare (loc, id); | 2483 ref = implicitly_declare (loc, id); |
2484 #endif | |
2462 else if (decl == error_mark_node) | 2485 else if (decl == error_mark_node) |
2463 /* Don't complain about something that's already been | 2486 /* Don't complain about something that's already been |
2464 complained about. */ | 2487 complained about. */ |
2465 return error_mark_node; | 2488 return error_mark_node; |
2466 else | 2489 else |
3160 typetail = TREE_CHAIN (typetail); | 3183 typetail = TREE_CHAIN (typetail); |
3161 } | 3184 } |
3162 | 3185 |
3163 gcc_assert (parmnum == VEC_length (tree, values)); | 3186 gcc_assert (parmnum == VEC_length (tree, values)); |
3164 | 3187 |
3188 #ifndef noCbC | |
3189 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node | |
3190 //&& !CbC_IS_CODE_SEGMENT(TREE_TYPE(fundecl)) ) | |
3191 && !(fundecl&&CbC_IS_CODE_SEGMENT(fundecl)) ) | |
3192 #else | |
3165 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) | 3193 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) |
3194 #endif | |
3166 { | 3195 { |
3167 error_at (input_location, | 3196 error_at (input_location, |
3168 "too few arguments to function %qE", function); | 3197 "too few arguments to function %qE", function); |
3169 if (fundecl && !DECL_BUILT_IN (fundecl)) | 3198 if (fundecl && !DECL_BUILT_IN (fundecl)) |
3170 inform (DECL_SOURCE_LOCATION (fundecl), "declared here"); | 3199 inform (DECL_SOURCE_LOCATION (fundecl), "declared here"); |