Mercurial > hg > CbC > CbC_gcc
comparison 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 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 112:ab0bcb71f44d |
---|---|
51 #include "spellcheck-tree.h" | 51 #include "spellcheck-tree.h" |
52 #include "gcc-rich-location.h" | 52 #include "gcc-rich-location.h" |
53 #include "stringpool.h" | 53 #include "stringpool.h" |
54 #include "attribs.h" | 54 #include "attribs.h" |
55 #include "asan.h" | 55 #include "asan.h" |
56 #ifndef noCbC | |
57 #include "cbc-tree.h" | |
58 #endif | |
56 | 59 |
57 /* Possible cases of implicit bad conversions. Used to select | 60 /* Possible cases of implicit bad conversions. Used to select |
58 diagnostic messages in convert_for_assignment. */ | 61 diagnostic messages in convert_for_assignment. */ |
59 enum impl_conv { | 62 enum impl_conv { |
60 ic_argpass, | 63 ic_argpass, |
493 | 496 |
494 case FUNCTION_TYPE: | 497 case FUNCTION_TYPE: |
495 /* Function types: prefer the one that specified arg types. | 498 /* Function types: prefer the one that specified arg types. |
496 If both do, merge the arg types. Also merge the return types. */ | 499 If both do, merge the arg types. Also merge the return types. */ |
497 { | 500 { |
501 #ifndef noCbC | |
502 int is_code_segment = CbC_IS_CODE_SEGMENT(t1); | |
503 #endif | |
498 tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2)); | 504 tree valtype = composite_type (TREE_TYPE (t1), TREE_TYPE (t2)); |
499 tree p1 = TYPE_ARG_TYPES (t1); | 505 tree p1 = TYPE_ARG_TYPES (t1); |
500 tree p2 = TYPE_ARG_TYPES (t2); | 506 tree p2 = TYPE_ARG_TYPES (t2); |
501 int len; | 507 int len; |
502 tree newargs, n; | 508 tree newargs, n; |
509 return build_type_attribute_variant (t2, attributes); | 515 return build_type_attribute_variant (t2, attributes); |
510 | 516 |
511 /* Simple way if one arg fails to specify argument types. */ | 517 /* Simple way if one arg fails to specify argument types. */ |
512 if (TYPE_ARG_TYPES (t1) == NULL_TREE) | 518 if (TYPE_ARG_TYPES (t1) == NULL_TREE) |
513 { | 519 { |
520 #ifndef noCbC | |
521 if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t2)); | |
522 else | |
523 #endif | |
514 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2)); | 524 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t2)); |
515 t1 = build_type_attribute_variant (t1, attributes); | 525 t1 = build_type_attribute_variant (t1, attributes); |
516 return qualify_type (t1, t2); | 526 return qualify_type (t1, t2); |
517 } | 527 } |
518 if (TYPE_ARG_TYPES (t2) == NULL_TREE) | 528 if (TYPE_ARG_TYPES (t2) == NULL_TREE) |
519 { | 529 { |
530 #ifndef noCbC | |
531 if (is_code_segment) t1 = build_code_segment_type (valtype, TYPE_ARG_TYPES (t1)); | |
532 else | |
533 #endif | |
520 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1)); | 534 t1 = build_function_type (valtype, TYPE_ARG_TYPES (t1)); |
521 t1 = build_type_attribute_variant (t1, attributes); | 535 t1 = build_type_attribute_variant (t1, attributes); |
522 return qualify_type (t1, t2); | 536 return qualify_type (t1, t2); |
523 } | 537 } |
524 | 538 |
606 } | 620 } |
607 TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2)); | 621 TREE_VALUE (n) = composite_type (TREE_VALUE (p1), TREE_VALUE (p2)); |
608 parm_done: ; | 622 parm_done: ; |
609 } | 623 } |
610 | 624 |
625 #ifndef noCbC | |
626 if (is_code_segment) t1 = build_code_segment_type (valtype, newargs); | |
627 else | |
628 #endif | |
629 | |
611 t1 = build_function_type (valtype, newargs); | 630 t1 = build_function_type (valtype, newargs); |
612 t1 = qualify_type (t1, t2); | 631 t1 = qualify_type (t1, t2); |
613 } | 632 } |
614 /* FALLTHRU */ | 633 /* FALLTHRU */ |
615 | 634 |
2755 ref = decl; | 2774 ref = decl; |
2756 *type = TREE_TYPE (ref); | 2775 *type = TREE_TYPE (ref); |
2757 } | 2776 } |
2758 else if (fun) | 2777 else if (fun) |
2759 /* Implicit function declaration. */ | 2778 /* Implicit function declaration. */ |
2779 #ifndef noCbC | |
2780 ref = implicitly_declare (loc, id, fun); | |
2781 #else | |
2760 ref = implicitly_declare (loc, id); | 2782 ref = implicitly_declare (loc, id); |
2783 #endif | |
2761 else if (decl == error_mark_node) | 2784 else if (decl == error_mark_node) |
2762 /* Don't complain about something that's already been | 2785 /* Don't complain about something that's already been |
2763 complained about. */ | 2786 complained about. */ |
2764 return error_mark_node; | 2787 return error_mark_node; |
2765 else | 2788 else |
3558 if (typetail) | 3581 if (typetail) |
3559 typetail = TREE_CHAIN (typetail); | 3582 typetail = TREE_CHAIN (typetail); |
3560 } | 3583 } |
3561 | 3584 |
3562 gcc_assert (parmnum == vec_safe_length (values)); | 3585 gcc_assert (parmnum == vec_safe_length (values)); |
3563 | 3586 fndef noCbC |
3564 if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node) | 3587 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node |
3588 //&& !CbC_IS_CODE_SEGMENT(TREE_TYPE(fundecl)) ) | |
3589 && !(fundecl&&CbC_IS_CODE_SEGMENT(fundecl)) ) | |
3590 #else | |
3591 if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) | |
3592 #endif | |
3565 { | 3593 { |
3566 error_at (loc, "too few arguments to function %qE", function); | 3594 error_at (loc, "too few arguments to function %qE", function); |
3567 inform_declaration (fundecl); | 3595 inform_declaration (fundecl); |
3568 return -1; | 3596 return -1; |
3569 } | 3597 } |