Mercurial > hg > CbC > CbC_gcc
comparison gcc/c/c-typeck.c @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | bdf41c9fa0b7 84e7813d76e9 |
children | 351920fa3827 |
comparison
equal
deleted
inserted
replaced
130:e108057fa461 | 132:d34655255c78 |
---|---|
1 /* Build expressions with type checking for C compiler. | 1 /* Build expressions with type checking for C compiler. |
2 Copyright (C) 1987-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1987-2018 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
44 #include "gimplify.h" | 44 #include "gimplify.h" |
45 #include "tree-inline.h" | 45 #include "tree-inline.h" |
46 #include "omp-general.h" | 46 #include "omp-general.h" |
47 #include "c-family/c-objc.h" | 47 #include "c-family/c-objc.h" |
48 #include "c-family/c-ubsan.h" | 48 #include "c-family/c-ubsan.h" |
49 #include "cilk.h" | |
50 #include "gomp-constants.h" | 49 #include "gomp-constants.h" |
51 #include "spellcheck-tree.h" | 50 #include "spellcheck-tree.h" |
52 #include "gcc-rich-location.h" | 51 #include "gcc-rich-location.h" |
53 #include "stringpool.h" | 52 #include "stringpool.h" |
54 #include "attribs.h" | 53 #include "attribs.h" |
97 static int type_lists_compatible_p (const_tree, const_tree, bool *, bool *); | 96 static int type_lists_compatible_p (const_tree, const_tree, bool *, bool *); |
98 static tree lookup_field (tree, tree); | 97 static tree lookup_field (tree, tree); |
99 static int convert_arguments (location_t, vec<location_t>, tree, | 98 static int convert_arguments (location_t, vec<location_t>, tree, |
100 vec<tree, va_gc> *, vec<tree, va_gc> *, tree, | 99 vec<tree, va_gc> *, vec<tree, va_gc> *, tree, |
101 tree); | 100 tree); |
102 static tree pointer_diff (location_t, tree, tree); | 101 static tree pointer_diff (location_t, tree, tree, tree *); |
103 static tree convert_for_assignment (location_t, location_t, tree, tree, tree, | 102 static tree convert_for_assignment (location_t, location_t, tree, tree, tree, |
104 enum impl_conv, bool, tree, tree, int); | 103 enum impl_conv, bool, tree, tree, int); |
105 static tree valid_compound_expr_initializer (tree, tree); | 104 static tree valid_compound_expr_initializer (tree, tree); |
106 static void push_string (const char *); | 105 static void push_string (const char *); |
107 static void push_member_name (tree); | 106 static void push_member_name (tree); |
1195 bool d1_zero, d2_zero; | 1194 bool d1_zero, d2_zero; |
1196 val = 1; | 1195 val = 1; |
1197 | 1196 |
1198 /* Target types must match incl. qualifiers. */ | 1197 /* Target types must match incl. qualifiers. */ |
1199 if (TREE_TYPE (t1) != TREE_TYPE (t2) | 1198 if (TREE_TYPE (t1) != TREE_TYPE (t2) |
1200 && 0 == (val = comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), | 1199 && (val = comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), |
1201 enum_and_int_p, | 1200 enum_and_int_p, |
1202 different_types_p))) | 1201 different_types_p)) == 0) |
1203 return 0; | 1202 return 0; |
1204 | 1203 |
1205 if (different_types_p != NULL | 1204 if (different_types_p != NULL |
1206 && (d1 == NULL_TREE) != (d2 == NULL_TREE)) | 1205 && (d1 == NULL_TREE) != (d2 == NULL_TREE)) |
1207 *different_types_p = true; | 1206 *different_types_p = true; |
1255 different_types_p); | 1254 different_types_p); |
1256 } | 1255 } |
1257 break; | 1256 break; |
1258 | 1257 |
1259 case VECTOR_TYPE: | 1258 case VECTOR_TYPE: |
1260 val = (TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2) | 1259 val = (known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2)) |
1261 && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), | 1260 && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), |
1262 enum_and_int_p, different_types_p)); | 1261 enum_and_int_p, different_types_p)); |
1263 break; | 1262 break; |
1264 | 1263 |
1265 default: | 1264 default: |
1680 return 0; | 1679 return 0; |
1681 /* If one of these types comes from a non-prototype fn definition, | 1680 /* If one of these types comes from a non-prototype fn definition, |
1682 compare that with the other type's arglist. | 1681 compare that with the other type's arglist. |
1683 If they don't match, ask for a warning (but no error). */ | 1682 If they don't match, ask for a warning (but no error). */ |
1684 if (TYPE_ACTUAL_ARG_TYPES (f1) | 1683 if (TYPE_ACTUAL_ARG_TYPES (f1) |
1685 && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1), | 1684 && type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1), |
1686 enum_and_int_p, different_types_p)) | 1685 enum_and_int_p, different_types_p) != 1) |
1687 val = 2; | 1686 val = 2; |
1688 return val; | 1687 return val; |
1689 } | 1688 } |
1690 if (args2 == NULL_TREE) | 1689 if (args2 == NULL_TREE) |
1691 { | 1690 { |
1692 if (!self_promoting_args_p (args1)) | 1691 if (!self_promoting_args_p (args1)) |
1693 return 0; | 1692 return 0; |
1694 if (TYPE_ACTUAL_ARG_TYPES (f2) | 1693 if (TYPE_ACTUAL_ARG_TYPES (f2) |
1695 && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2), | 1694 && type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2), |
1696 enum_and_int_p, different_types_p)) | 1695 enum_and_int_p, different_types_p) != 1) |
1697 val = 2; | 1696 val = 2; |
1698 return val; | 1697 return val; |
1699 } | 1698 } |
1700 | 1699 |
1701 /* Both types have argument lists: compare them and propagate results. */ | 1700 /* Both types have argument lists: compare them and propagate results. */ |
1850 } | 1849 } |
1851 | 1850 |
1852 /* Return either DECL or its known constant value (if it has one). */ | 1851 /* Return either DECL or its known constant value (if it has one). */ |
1853 | 1852 |
1854 tree | 1853 tree |
1855 decl_constant_value (tree decl) | 1854 decl_constant_value_1 (tree decl, bool in_init) |
1856 { | 1855 { |
1857 if (/* Don't change a variable array bound or initial value to a constant | 1856 if (/* Note that DECL_INITIAL isn't valid for a PARM_DECL. */ |
1858 in a place where a variable is invalid. Note that DECL_INITIAL | 1857 TREE_CODE (decl) != PARM_DECL |
1859 isn't valid for a PARM_DECL. */ | |
1860 current_function_decl != NULL_TREE | |
1861 && TREE_CODE (decl) != PARM_DECL | |
1862 && !TREE_THIS_VOLATILE (decl) | 1858 && !TREE_THIS_VOLATILE (decl) |
1863 && TREE_READONLY (decl) | 1859 && TREE_READONLY (decl) |
1864 && DECL_INITIAL (decl) != NULL_TREE | 1860 && DECL_INITIAL (decl) != NULL_TREE |
1865 && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK | 1861 && !error_operand_p (DECL_INITIAL (decl)) |
1866 /* This is invalid if initial value is not constant. | 1862 /* This is invalid if initial value is not constant. |
1867 If it has either a function call, a memory reference, | 1863 If it has either a function call, a memory reference, |
1868 or a variable, then re-evaluating it could give different results. */ | 1864 or a variable, then re-evaluating it could give different results. */ |
1869 && TREE_CONSTANT (DECL_INITIAL (decl)) | 1865 && TREE_CONSTANT (DECL_INITIAL (decl)) |
1870 /* Check for cases where this is sub-optimal, even though valid. */ | 1866 /* Check for cases where this is sub-optimal, even though valid. */ |
1871 && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR) | 1867 && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR)) |
1872 return DECL_INITIAL (decl); | 1868 return DECL_INITIAL (decl); |
1873 return decl; | 1869 return decl; |
1870 } | |
1871 | |
1872 /* Return either DECL or its known constant value (if it has one). | |
1873 Like the above, but always return decl outside of functions. */ | |
1874 | |
1875 tree | |
1876 decl_constant_value (tree decl) | |
1877 { | |
1878 /* Don't change a variable array bound or initial value to a constant | |
1879 in a place where a variable is invalid. */ | |
1880 return current_function_decl ? decl_constant_value_1 (decl, false) : decl; | |
1874 } | 1881 } |
1875 | 1882 |
1876 /* Convert the array expression EXP to a pointer. */ | 1883 /* Convert the array expression EXP to a pointer. */ |
1877 static tree | 1884 static tree |
1878 array_to_pointer_conversion (location_t loc, tree exp) | 1885 array_to_pointer_conversion (location_t loc, tree exp) |
2131 proper types. */ | 2138 proper types. */ |
2132 if (TREE_CODE (exp) == COMPONENT_REF | 2139 if (TREE_CODE (exp) == COMPONENT_REF |
2133 && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)) | 2140 && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)) |
2134 /* If it's thinner than an int, promote it like a | 2141 /* If it's thinner than an int, promote it like a |
2135 c_promoting_integer_type_p, otherwise leave it alone. */ | 2142 c_promoting_integer_type_p, otherwise leave it alone. */ |
2136 && 0 > compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)), | 2143 && compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)), |
2137 TYPE_PRECISION (integer_type_node))) | 2144 TYPE_PRECISION (integer_type_node)) < 0) |
2138 return convert (integer_type_node, exp); | 2145 return convert (integer_type_node, exp); |
2139 | 2146 |
2140 if (c_promoting_integer_type_p (type)) | 2147 if (c_promoting_integer_type_p (type)) |
2141 { | 2148 { |
2142 /* Preserve unsignedness if not really getting any wider. */ | 2149 /* Preserve unsignedness if not really getting any wider. */ |
2217 tree field; | 2224 tree field; |
2218 | 2225 |
2219 /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers | 2226 /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers |
2220 to the field elements. Use a binary search on this array to quickly | 2227 to the field elements. Use a binary search on this array to quickly |
2221 find the element. Otherwise, do a linear search. TYPE_LANG_SPECIFIC | 2228 find the element. Otherwise, do a linear search. TYPE_LANG_SPECIFIC |
2222 will always be set for structures which have many elements. */ | 2229 will always be set for structures which have many elements. |
2223 | 2230 |
2224 if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s) | 2231 Duplicate field checking replaces duplicates with NULL_TREE so |
2232 TYPE_LANG_SPECIFIC arrays are potentially no longer sorted. In that | |
2233 case just iterate using DECL_CHAIN. */ | |
2234 | |
2235 if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s | |
2236 && !seen_error ()) | |
2225 { | 2237 { |
2226 int bot, top, half; | 2238 int bot, top, half; |
2227 tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0]; | 2239 tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0]; |
2228 | 2240 |
2229 field = TYPE_FIELDS (type); | 2241 field = TYPE_FIELDS (type); |
2423 location_t reported_loc | 2435 location_t reported_loc |
2424 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc; | 2436 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc; |
2425 gcc_rich_location rich_loc (reported_loc); | 2437 gcc_rich_location rich_loc (reported_loc); |
2426 if (component_loc != UNKNOWN_LOCATION) | 2438 if (component_loc != UNKNOWN_LOCATION) |
2427 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id); | 2439 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id); |
2428 error_at_rich_loc | 2440 error_at (&rich_loc, |
2429 (&rich_loc, | 2441 "%qT has no member named %qE; did you mean %qE?", |
2430 "%qT has no member named %qE; did you mean %qE?", | 2442 type, component, guessed_id); |
2431 type, component, guessed_id); | |
2432 } | 2443 } |
2433 else | 2444 else |
2434 error_at (loc, "%qT has no member named %qE", type, component); | 2445 error_at (loc, "%qT has no member named %qE", type, component); |
2435 return error_mark_node; | 2446 return error_mark_node; |
2436 } | 2447 } |
2500 /* Special-case the error message for "ptr.field" for the case | 2511 /* Special-case the error message for "ptr.field" for the case |
2501 where the user has confused "." vs "->". */ | 2512 where the user has confused "." vs "->". */ |
2502 rich_location richloc (line_table, loc); | 2513 rich_location richloc (line_table, loc); |
2503 /* "loc" should be the "." token. */ | 2514 /* "loc" should be the "." token. */ |
2504 richloc.add_fixit_replace ("->"); | 2515 richloc.add_fixit_replace ("->"); |
2505 error_at_rich_loc (&richloc, | 2516 error_at (&richloc, |
2506 "%qE is a pointer; did you mean to use %<->%>?", | 2517 "%qE is a pointer; did you mean to use %<->%>?", |
2507 datum); | 2518 datum); |
2508 return error_mark_node; | 2519 return error_mark_node; |
2509 } | 2520 } |
2510 else if (code != ERROR_MARK) | 2521 else if (code != ERROR_MARK) |
2511 error_at (loc, | 2522 error_at (loc, |
2512 "request for member %qE in something not a structure or union", | 2523 "request for member %qE in something not a structure or union", |
2535 { | 2546 { |
2536 /* If a warning is issued, mark it to avoid duplicates from | 2547 /* If a warning is issued, mark it to avoid duplicates from |
2537 the backend. This only needs to be done at | 2548 the backend. This only needs to be done at |
2538 warn_strict_aliasing > 2. */ | 2549 warn_strict_aliasing > 2. */ |
2539 if (warn_strict_aliasing > 2) | 2550 if (warn_strict_aliasing > 2) |
2540 if (strict_aliasing_warning (TREE_TYPE (TREE_OPERAND (pointer, 0)), | 2551 if (strict_aliasing_warning (EXPR_LOCATION (pointer), |
2541 type, TREE_OPERAND (pointer, 0))) | 2552 type, TREE_OPERAND (pointer, 0))) |
2542 TREE_NO_WARNING (pointer) = 1; | 2553 TREE_NO_WARNING (pointer) = 1; |
2543 } | 2554 } |
2544 | 2555 |
2545 if (TREE_CODE (pointer) == ADDR_EXPR | 2556 if (TREE_CODE (pointer) == ADDR_EXPR |
2611 bool swapped = false; | 2622 bool swapped = false; |
2612 if (TREE_TYPE (array) == error_mark_node | 2623 if (TREE_TYPE (array) == error_mark_node |
2613 || TREE_TYPE (index) == error_mark_node) | 2624 || TREE_TYPE (index) == error_mark_node) |
2614 return error_mark_node; | 2625 return error_mark_node; |
2615 | 2626 |
2616 if (flag_cilkplus && contains_array_notation_expr (index)) | |
2617 { | |
2618 size_t rank = 0; | |
2619 if (!find_rank (loc, index, index, true, &rank)) | |
2620 return error_mark_node; | |
2621 if (rank > 1) | |
2622 { | |
2623 error_at (loc, "rank of the array's index is greater than 1"); | |
2624 return error_mark_node; | |
2625 } | |
2626 } | |
2627 if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE | 2627 if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE |
2628 && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE | 2628 && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE |
2629 /* Allow vector[index] but not index[vector]. */ | 2629 /* Allow vector[index] but not index[vector]. */ |
2630 && !VECTOR_TYPE_P (TREE_TYPE (array))) | 2630 && !VECTOR_TYPE_P (TREE_TYPE (array))) |
2631 { | 2631 { |
2927 bool expr_const_operands = true; | 2927 bool expr_const_operands = true; |
2928 | 2928 |
2929 if (TREE_CODE (expr.value) == PARM_DECL | 2929 if (TREE_CODE (expr.value) == PARM_DECL |
2930 && C_ARRAY_PARAMETER (expr.value)) | 2930 && C_ARRAY_PARAMETER (expr.value)) |
2931 { | 2931 { |
2932 auto_diagnostic_group d; | |
2932 if (warning_at (loc, OPT_Wsizeof_array_argument, | 2933 if (warning_at (loc, OPT_Wsizeof_array_argument, |
2933 "%<sizeof%> on array function parameter %qE will " | 2934 "%<sizeof%> on array function parameter %qE will " |
2934 "return size of %qT", expr.value, | 2935 "return size of %qT", expr.value, |
2935 TREE_TYPE (expr.value))) | 2936 TREE_TYPE (expr.value))) |
2936 inform (DECL_SOURCE_LOCATION (expr.value), "declared here"); | 2937 inform (DECL_SOURCE_LOCATION (expr.value), "declared here"); |
3055 fundecl = function; | 3056 fundecl = function; |
3056 /* Atomic functions have type checking/casting already done. They are | 3057 /* Atomic functions have type checking/casting already done. They are |
3057 often rewritten and don't match the original parameter list. */ | 3058 often rewritten and don't match the original parameter list. */ |
3058 if (name && !strncmp (IDENTIFIER_POINTER (name), "__atomic_", 9)) | 3059 if (name && !strncmp (IDENTIFIER_POINTER (name), "__atomic_", 9)) |
3059 origtypes = NULL; | 3060 origtypes = NULL; |
3060 | |
3061 if (flag_cilkplus | |
3062 && is_cilkplus_reduce_builtin (function)) | |
3063 origtypes = NULL; | |
3064 } | 3061 } |
3065 if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE) | 3062 if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE) |
3066 function = function_to_pointer_conversion (loc, function); | 3063 function = function_to_pointer_conversion (loc, function); |
3067 | 3064 |
3068 /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF | 3065 /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF |
3132 } | 3129 } |
3133 | 3130 |
3134 argarray = vec_safe_address (params); | 3131 argarray = vec_safe_address (params); |
3135 | 3132 |
3136 /* Check that arguments to builtin functions match the expectations. */ | 3133 /* Check that arguments to builtin functions match the expectations. */ |
3137 if (fundecl | 3134 if (fundecl && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL) |
3138 && DECL_BUILT_IN (fundecl) | |
3139 && DECL_BUILT_IN_CLASS (fundecl) == BUILT_IN_NORMAL | |
3140 && !check_builtin_function_arguments (loc, arg_loc, fundecl, nargs, | 3135 && !check_builtin_function_arguments (loc, arg_loc, fundecl, nargs, |
3141 argarray)) | 3136 argarray)) |
3142 return error_mark_node; | 3137 return error_mark_node; |
3143 | 3138 |
3144 /* Check that the arguments to the function are valid. */ | 3139 /* Check that the arguments to the function are valid. */ |
3257 | 3252 |
3258 /* For type-generic built-in functions, determine whether excess | 3253 /* For type-generic built-in functions, determine whether excess |
3259 precision should be removed (classification) or not | 3254 precision should be removed (classification) or not |
3260 (comparison). */ | 3255 (comparison). */ |
3261 if (type_generic | 3256 if (type_generic |
3262 && DECL_BUILT_IN (fundecl) | 3257 && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL)) |
3263 && DECL_BUILT_IN_CLASS (fundecl) == BUILT_IN_NORMAL) | |
3264 { | 3258 { |
3265 switch (DECL_FUNCTION_CODE (fundecl)) | 3259 switch (DECL_FUNCTION_CODE (fundecl)) |
3266 { | 3260 { |
3267 case BUILT_IN_ISFINITE: | 3261 case BUILT_IN_ISFINITE: |
3268 case BUILT_IN_ISINF: | 3262 case BUILT_IN_ISINF: |
3283 | 3277 |
3284 default: | 3278 default: |
3285 break; | 3279 break; |
3286 } | 3280 } |
3287 } | 3281 } |
3288 if (flag_cilkplus && fundecl && is_cilkplus_reduce_builtin (fundecl)) | |
3289 return vec_safe_length (values); | |
3290 | 3282 |
3291 /* Scan the given expressions and types, producing individual | 3283 /* Scan the given expressions and types, producing individual |
3292 converted arguments. */ | 3284 converted arguments. */ |
3293 | 3285 |
3294 for (typetail = typelist, parmnum = 0; | 3286 for (typetail = typelist, parmnum = 0; |
3767 && !integer_zerop (tree_strip_nop_conversions (arg1.value)))) | 3759 && !integer_zerop (tree_strip_nop_conversions (arg1.value)))) |
3768 warning_at (location, OPT_Waddress, | 3760 warning_at (location, OPT_Waddress, |
3769 "comparison with string literal results in unspecified behavior"); | 3761 "comparison with string literal results in unspecified behavior"); |
3770 /* Warn for ptr == '\0', it's likely that it should've been ptr[0]. */ | 3762 /* Warn for ptr == '\0', it's likely that it should've been ptr[0]. */ |
3771 if (POINTER_TYPE_P (type1) | 3763 if (POINTER_TYPE_P (type1) |
3772 && null_pointer_constant_p (arg2.value) | 3764 && null_pointer_constant_p (arg2.value) |
3773 && char_type_p (type2) | 3765 && char_type_p (type2)) |
3774 && warning_at (location, OPT_Wpointer_compare, | 3766 { |
3775 "comparison between pointer and zero character " | 3767 auto_diagnostic_group d; |
3776 "constant")) | 3768 if (warning_at (location, OPT_Wpointer_compare, |
3777 inform (arg1.get_start (), "did you mean to dereference the pointer?"); | 3769 "comparison between pointer and zero character " |
3770 "constant")) | |
3771 inform (arg1.get_start (), | |
3772 "did you mean to dereference the pointer?"); | |
3773 } | |
3778 else if (POINTER_TYPE_P (type2) | 3774 else if (POINTER_TYPE_P (type2) |
3779 && null_pointer_constant_p (arg1.value) | 3775 && null_pointer_constant_p (arg1.value) |
3780 && char_type_p (type1) | 3776 && char_type_p (type1)) |
3781 && warning_at (location, OPT_Wpointer_compare, | 3777 { |
3782 "comparison between pointer and zero character " | 3778 auto_diagnostic_group d; |
3783 "constant")) | 3779 if (warning_at (location, OPT_Wpointer_compare, |
3784 inform (arg2.get_start (), "did you mean to dereference the pointer?"); | 3780 "comparison between pointer and zero character " |
3781 "constant")) | |
3782 inform (arg2.get_start (), | |
3783 "did you mean to dereference the pointer?"); | |
3784 } | |
3785 } | 3785 } |
3786 else if (TREE_CODE_CLASS (code) == tcc_comparison | 3786 else if (TREE_CODE_CLASS (code) == tcc_comparison |
3787 && (code1 == STRING_CST || code2 == STRING_CST)) | 3787 && (code1 == STRING_CST || code2 == STRING_CST)) |
3788 warning_at (location, OPT_Waddress, | 3788 warning_at (location, OPT_Waddress, |
3789 "comparison with string literal results in unspecified behavior"); | 3789 "comparison with string literal results in unspecified behavior"); |
3805 | 3805 |
3806 return result; | 3806 return result; |
3807 } | 3807 } |
3808 | 3808 |
3809 /* Return a tree for the difference of pointers OP0 and OP1. | 3809 /* Return a tree for the difference of pointers OP0 and OP1. |
3810 The resulting tree has type int. */ | 3810 The resulting tree has type ptrdiff_t. If POINTER_SUBTRACT sanitization is |
3811 enabled, assign to INSTRUMENT_EXPR call to libsanitizer. */ | |
3811 | 3812 |
3812 static tree | 3813 static tree |
3813 pointer_diff (location_t loc, tree op0, tree op1) | 3814 pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr) |
3814 { | 3815 { |
3815 tree restype = ptrdiff_type_node; | 3816 tree restype = ptrdiff_type_node; |
3816 tree result, inttype; | 3817 tree result, inttype; |
3817 | 3818 |
3818 addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0))); | 3819 addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0))); |
3837 common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1)); | 3838 common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1)); |
3838 op0 = convert (common_type, op0); | 3839 op0 = convert (common_type, op0); |
3839 op1 = convert (common_type, op1); | 3840 op1 = convert (common_type, op1); |
3840 } | 3841 } |
3841 | 3842 |
3842 /* Determine integer type to perform computations in. This will usually | 3843 /* Determine integer type result of the subtraction. This will usually |
3843 be the same as the result type (ptrdiff_t), but may need to be a wider | 3844 be the same as the result type (ptrdiff_t), but may need to be a wider |
3844 type if pointers for the address space are wider than ptrdiff_t. */ | 3845 type if pointers for the address space are wider than ptrdiff_t. */ |
3845 if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0))) | 3846 if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0))) |
3846 inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0); | 3847 inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0); |
3847 else | 3848 else |
3852 "pointer of type %<void *%> used in subtraction"); | 3853 "pointer of type %<void *%> used in subtraction"); |
3853 if (TREE_CODE (target_type) == FUNCTION_TYPE) | 3854 if (TREE_CODE (target_type) == FUNCTION_TYPE) |
3854 pedwarn (loc, OPT_Wpointer_arith, | 3855 pedwarn (loc, OPT_Wpointer_arith, |
3855 "pointer to a function used in subtraction"); | 3856 "pointer to a function used in subtraction"); |
3856 | 3857 |
3857 /* First do the subtraction as integers; | 3858 if (sanitize_flags_p (SANITIZE_POINTER_SUBTRACT)) |
3858 then drop through to build the divide operator. | 3859 { |
3859 Do not do default conversions on the minus operator | 3860 gcc_assert (current_function_decl != NULL_TREE); |
3860 in case restype is a short type. */ | 3861 |
3861 | 3862 op0 = save_expr (op0); |
3862 op0 = build_binary_op (loc, | 3863 op1 = save_expr (op1); |
3863 MINUS_EXPR, convert (inttype, op0), | 3864 |
3864 convert (inttype, op1), false); | 3865 tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT); |
3866 *instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1); | |
3867 } | |
3868 | |
3869 /* First do the subtraction, then build the divide operator | |
3870 and only convert at the very end. | |
3871 Do not do default conversions in case restype is a short type. */ | |
3872 | |
3873 /* POINTER_DIFF_EXPR requires a signed integer type of the same size as | |
3874 pointers. If some platform cannot provide that, or has a larger | |
3875 ptrdiff_type to support differences larger than half the address | |
3876 space, cast the pointers to some larger integer type and do the | |
3877 computations in that type. */ | |
3878 if (TYPE_PRECISION (inttype) > TYPE_PRECISION (TREE_TYPE (op0))) | |
3879 op0 = build_binary_op (loc, MINUS_EXPR, convert (inttype, op0), | |
3880 convert (inttype, op1), false); | |
3881 else | |
3882 { | |
3883 /* Cast away qualifiers. */ | |
3884 op0 = convert (c_common_type (TREE_TYPE (op0), TREE_TYPE (op0)), op0); | |
3885 op1 = convert (c_common_type (TREE_TYPE (op1), TREE_TYPE (op1)), op1); | |
3886 op0 = build2_loc (loc, POINTER_DIFF_EXPR, inttype, op0, op1); | |
3887 } | |
3888 | |
3865 /* This generates an error if op1 is pointer to incomplete type. */ | 3889 /* This generates an error if op1 is pointer to incomplete type. */ |
3866 if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1)))) | 3890 if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1)))) |
3867 error_at (loc, "arithmetic on pointer to an incomplete type"); | 3891 error_at (loc, "arithmetic on pointer to an incomplete type"); |
3868 | 3892 |
3869 op1 = c_size_in_bytes (target_type); | 3893 op1 = c_size_in_bytes (target_type); |
4296 /* Warn if the expression has boolean value. */ | 4320 /* Warn if the expression has boolean value. */ |
4297 while (TREE_CODE (e) == COMPOUND_EXPR) | 4321 while (TREE_CODE (e) == COMPOUND_EXPR) |
4298 e = TREE_OPERAND (e, 1); | 4322 e = TREE_OPERAND (e, 1); |
4299 | 4323 |
4300 if ((TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE | 4324 if ((TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE |
4301 || truth_value_p (TREE_CODE (e))) | 4325 || truth_value_p (TREE_CODE (e)))) |
4302 && warning_at (location, OPT_Wbool_operation, | 4326 { |
4303 "%<~%> on a boolean expression")) | 4327 auto_diagnostic_group d; |
4304 { | 4328 if (warning_at (location, OPT_Wbool_operation, |
4305 gcc_rich_location richloc (location); | 4329 "%<~%> on a boolean expression")) |
4306 richloc.add_fixit_insert_before (location, "!"); | 4330 { |
4307 inform_at_rich_loc (&richloc, "did you mean to use logical " | 4331 gcc_rich_location richloc (location); |
4308 "not?"); | 4332 richloc.add_fixit_insert_before (location, "!"); |
4333 inform (&richloc, "did you mean to use logical not?"); | |
4334 } | |
4309 } | 4335 } |
4310 if (!noconvert) | 4336 if (!noconvert) |
4311 arg = default_conversion (arg); | 4337 arg = default_conversion (arg); |
4312 } | 4338 } |
4313 else if (typecode == COMPLEX_TYPE) | 4339 else if (typecode == COMPLEX_TYPE) |
4327 | 4353 |
4328 case ABS_EXPR: | 4354 case ABS_EXPR: |
4329 if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE)) | 4355 if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE)) |
4330 { | 4356 { |
4331 error_at (location, "wrong type argument to abs"); | 4357 error_at (location, "wrong type argument to abs"); |
4358 return error_mark_node; | |
4359 } | |
4360 else if (!noconvert) | |
4361 arg = default_conversion (arg); | |
4362 break; | |
4363 | |
4364 case ABSU_EXPR: | |
4365 if (!(typecode == INTEGER_TYPE)) | |
4366 { | |
4367 error_at (location, "wrong type argument to absu"); | |
4332 return error_mark_node; | 4368 return error_mark_node; |
4333 } | 4369 } |
4334 else if (!noconvert) | 4370 else if (!noconvert) |
4335 arg = default_conversion (arg); | 4371 arg = default_conversion (arg); |
4336 break; | 4372 break; |
4426 warning_at (location, OPT_Wbool_operation, | 4462 warning_at (location, OPT_Wbool_operation, |
4427 "decrement of a boolean expression"); | 4463 "decrement of a boolean expression"); |
4428 } | 4464 } |
4429 | 4465 |
4430 /* Ensure the argument is fully folded inside any SAVE_EXPR. */ | 4466 /* Ensure the argument is fully folded inside any SAVE_EXPR. */ |
4431 arg = c_fully_fold (arg, false, NULL); | 4467 arg = c_fully_fold (arg, false, NULL, true); |
4432 | 4468 |
4433 bool atomic_op; | 4469 bool atomic_op; |
4434 atomic_op = really_atomic_lvalue (arg); | 4470 atomic_op = really_atomic_lvalue (arg); |
4435 | 4471 |
4436 /* Increment or decrement the real part of the value, | 4472 /* Increment or decrement the real part of the value, |
4695 when we have proper support for integer constant expressions. */ | 4731 when we have proper support for integer constant expressions. */ |
4696 val = get_base_address (arg); | 4732 val = get_base_address (arg); |
4697 if (val && INDIRECT_REF_P (val) | 4733 if (val && INDIRECT_REF_P (val) |
4698 && TREE_CONSTANT (TREE_OPERAND (val, 0))) | 4734 && TREE_CONSTANT (TREE_OPERAND (val, 0))) |
4699 { | 4735 { |
4700 ret = fold_convert_loc (location, argtype, fold_offsetof_1 (arg)); | 4736 ret = fold_offsetof (arg, argtype); |
4701 goto return_build_unary_op; | 4737 goto return_build_unary_op; |
4702 } | 4738 } |
4703 | 4739 |
4704 val = build1 (ADDR_EXPR, argtype, arg); | 4740 val = build1 (ADDR_EXPR, argtype, arg); |
4705 | 4741 |
4754 case STRING_CST: | 4790 case STRING_CST: |
4755 return true; | 4791 return true; |
4756 | 4792 |
4757 case INDIRECT_REF: | 4793 case INDIRECT_REF: |
4758 case ARRAY_REF: | 4794 case ARRAY_REF: |
4759 case ARRAY_NOTATION_REF: | |
4760 case VAR_DECL: | 4795 case VAR_DECL: |
4761 case PARM_DECL: | 4796 case PARM_DECL: |
4762 case RESULT_DECL: | 4797 case RESULT_DECL: |
4763 case ERROR_MARK: | 4798 case ERROR_MARK: |
4764 return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE | 4799 return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE |
4841 case IMAGPART_EXPR: | 4876 case IMAGPART_EXPR: |
4842 x = TREE_OPERAND (x, 0); | 4877 x = TREE_OPERAND (x, 0); |
4843 break; | 4878 break; |
4844 | 4879 |
4845 case COMPOUND_LITERAL_EXPR: | 4880 case COMPOUND_LITERAL_EXPR: |
4881 TREE_ADDRESSABLE (x) = 1; | |
4882 TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1; | |
4883 return true; | |
4884 | |
4846 case CONSTRUCTOR: | 4885 case CONSTRUCTOR: |
4847 TREE_ADDRESSABLE (x) = 1; | 4886 TREE_ADDRESSABLE (x) = 1; |
4848 return true; | 4887 return true; |
4849 | 4888 |
4850 case VAR_DECL: | 4889 case VAR_DECL: |
5322 { | 5361 { |
5323 bool expr1_int_operands, expr2_int_operands; | 5362 bool expr1_int_operands, expr2_int_operands; |
5324 tree eptype = NULL_TREE; | 5363 tree eptype = NULL_TREE; |
5325 tree ret; | 5364 tree ret; |
5326 | 5365 |
5327 if (flag_cilkplus | |
5328 && (TREE_CODE (expr1) == CILK_SPAWN_STMT | |
5329 || TREE_CODE (expr2) == CILK_SPAWN_STMT)) | |
5330 { | |
5331 error_at (loc, | |
5332 "spawned function call cannot be part of a comma expression"); | |
5333 return error_mark_node; | |
5334 } | |
5335 expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1); | 5366 expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1); |
5336 if (expr1_int_operands) | 5367 if (expr1_int_operands) |
5337 expr1 = remove_c_maybe_const_expr (expr1); | 5368 expr1 = remove_c_maybe_const_expr (expr1); |
5338 expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2); | 5369 expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2); |
5339 if (expr2_int_operands) | 5370 if (expr2_int_operands) |
5498 } | 5529 } |
5499 if (is_const) | 5530 if (is_const) |
5500 is_const = TYPE_READONLY (in_type); | 5531 is_const = TYPE_READONLY (in_type); |
5501 } | 5532 } |
5502 while (TREE_CODE (in_type) == POINTER_TYPE); | 5533 while (TREE_CODE (in_type) == POINTER_TYPE); |
5534 } | |
5535 | |
5536 /* Heuristic check if two parameter types can be considered ABI-equivalent. */ | |
5537 | |
5538 static bool | |
5539 c_safe_arg_type_equiv_p (tree t1, tree t2) | |
5540 { | |
5541 t1 = TYPE_MAIN_VARIANT (t1); | |
5542 t2 = TYPE_MAIN_VARIANT (t2); | |
5543 | |
5544 if (TREE_CODE (t1) == POINTER_TYPE | |
5545 && TREE_CODE (t2) == POINTER_TYPE) | |
5546 return true; | |
5547 | |
5548 /* The signedness of the parameter matters only when an integral | |
5549 type smaller than int is promoted to int, otherwise only the | |
5550 precision of the parameter matters. | |
5551 This check should make sure that the callee does not see | |
5552 undefined values in argument registers. */ | |
5553 if (INTEGRAL_TYPE_P (t1) | |
5554 && INTEGRAL_TYPE_P (t2) | |
5555 && TYPE_PRECISION (t1) == TYPE_PRECISION (t2) | |
5556 && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2) | |
5557 || !targetm.calls.promote_prototypes (NULL_TREE) | |
5558 || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node))) | |
5559 return true; | |
5560 | |
5561 return comptypes (t1, t2); | |
5562 } | |
5563 | |
5564 /* Check if a type cast between two function types can be considered safe. */ | |
5565 | |
5566 static bool | |
5567 c_safe_function_type_cast_p (tree t1, tree t2) | |
5568 { | |
5569 if (TREE_TYPE (t1) == void_type_node && | |
5570 TYPE_ARG_TYPES (t1) == void_list_node) | |
5571 return true; | |
5572 | |
5573 if (TREE_TYPE (t2) == void_type_node && | |
5574 TYPE_ARG_TYPES (t2) == void_list_node) | |
5575 return true; | |
5576 | |
5577 if (!c_safe_arg_type_equiv_p (TREE_TYPE (t1), TREE_TYPE (t2))) | |
5578 return false; | |
5579 | |
5580 for (t1 = TYPE_ARG_TYPES (t1), t2 = TYPE_ARG_TYPES (t2); | |
5581 t1 && t2; | |
5582 t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2)) | |
5583 if (!c_safe_arg_type_equiv_p (TREE_VALUE (t1), TREE_VALUE (t2))) | |
5584 return false; | |
5585 | |
5586 return true; | |
5503 } | 5587 } |
5504 | 5588 |
5505 /* Build an expression representing a cast to type TYPE of expression EXPR. | 5589 /* Build an expression representing a cast to type TYPE of expression EXPR. |
5506 LOC is the location of the cast-- typically the open paren of the cast. */ | 5590 LOC is the location of the cast-- typically the open paren of the cast. */ |
5507 | 5591 |
5671 warning_at (loc, | 5755 warning_at (loc, |
5672 OPT_Wint_to_pointer_cast, "cast to pointer from integer " | 5756 OPT_Wint_to_pointer_cast, "cast to pointer from integer " |
5673 "of different size"); | 5757 "of different size"); |
5674 | 5758 |
5675 if (warn_strict_aliasing <= 2) | 5759 if (warn_strict_aliasing <= 2) |
5676 strict_aliasing_warning (otype, type, expr); | 5760 strict_aliasing_warning (EXPR_LOCATION (value), type, expr); |
5677 | 5761 |
5678 /* If pedantic, warn for conversions between function and object | 5762 /* If pedantic, warn for conversions between function and object |
5679 pointer types, except for converting a null pointer constant | 5763 pointer types, except for converting a null pointer constant |
5680 to function pointer type. */ | 5764 to function pointer type. */ |
5681 if (pedantic | 5765 if (pedantic |
5692 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE | 5776 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE |
5693 && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE | 5777 && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE |
5694 && !null_pointer_constant_p (value)) | 5778 && !null_pointer_constant_p (value)) |
5695 pedwarn (loc, OPT_Wpedantic, "ISO C forbids " | 5779 pedwarn (loc, OPT_Wpedantic, "ISO C forbids " |
5696 "conversion of object pointer to function pointer type"); | 5780 "conversion of object pointer to function pointer type"); |
5781 | |
5782 if (TREE_CODE (type) == POINTER_TYPE | |
5783 && TREE_CODE (otype) == POINTER_TYPE | |
5784 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE | |
5785 && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE | |
5786 && !c_safe_function_type_cast_p (TREE_TYPE (type), | |
5787 TREE_TYPE (otype))) | |
5788 warning_at (loc, OPT_Wcast_function_type, | |
5789 "cast between incompatible function types" | |
5790 " from %qT to %qT", otype, type); | |
5697 | 5791 |
5698 ovalue = value; | 5792 ovalue = value; |
5699 value = convert (type, value); | 5793 value = convert (type, value); |
5700 | 5794 |
5701 /* Ignore any integer overflow caused by the cast. */ | 5795 /* Ignore any integer overflow caused by the cast. */ |
5850 /* If a binary op has been requested, combine the old LHS value with the RHS | 5944 /* If a binary op has been requested, combine the old LHS value with the RHS |
5851 producing the value we should actually store into the LHS. */ | 5945 producing the value we should actually store into the LHS. */ |
5852 | 5946 |
5853 if (modifycode != NOP_EXPR) | 5947 if (modifycode != NOP_EXPR) |
5854 { | 5948 { |
5855 lhs = c_fully_fold (lhs, false, NULL); | 5949 lhs = c_fully_fold (lhs, false, NULL, true); |
5856 lhs = stabilize_reference (lhs); | 5950 lhs = stabilize_reference (lhs); |
5857 | 5951 |
5858 /* Construct the RHS for any non-atomic compound assignemnt. */ | 5952 /* Construct the RHS for any non-atomic compound assignemnt. */ |
5859 if (!is_atomic_op) | 5953 if (!is_atomic_op) |
5860 { | 5954 { |
6138 static void | 6232 static void |
6139 error_init (location_t loc, const char *gmsgid) | 6233 error_init (location_t loc, const char *gmsgid) |
6140 { | 6234 { |
6141 char *ofwhat; | 6235 char *ofwhat; |
6142 | 6236 |
6237 auto_diagnostic_group d; | |
6238 | |
6143 /* The gmsgid may be a format string with %< and %>. */ | 6239 /* The gmsgid may be a format string with %< and %>. */ |
6144 error_at (loc, gmsgid); | 6240 error_at (loc, gmsgid); |
6145 ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); | 6241 ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); |
6146 if (*ofwhat) | 6242 if (*ofwhat) |
6147 inform (loc, "(near initialization for %qs)", ofwhat); | 6243 inform (loc, "(near initialization for %qs)", ofwhat); |
6157 { | 6253 { |
6158 /* Use the location where a macro was expanded rather than where | 6254 /* Use the location where a macro was expanded rather than where |
6159 it was defined to make sure macros defined in system headers | 6255 it was defined to make sure macros defined in system headers |
6160 but used incorrectly elsewhere are diagnosed. */ | 6256 but used incorrectly elsewhere are diagnosed. */ |
6161 source_location exploc = expansion_point_location_if_in_system_header (loc); | 6257 source_location exploc = expansion_point_location_if_in_system_header (loc); |
6162 | 6258 auto_diagnostic_group d; |
6163 va_list ap; | 6259 va_list ap; |
6164 va_start (ap, gmsgid); | 6260 va_start (ap, gmsgid); |
6165 bool warned = emit_diagnostic_valist (DK_PEDWARN, exploc, opt, gmsgid, &ap); | 6261 bool warned = emit_diagnostic_valist (DK_PEDWARN, exploc, opt, gmsgid, &ap); |
6166 va_end (ap); | 6262 va_end (ap); |
6167 char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); | 6263 char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1)); |
6178 static void | 6274 static void |
6179 warning_init (location_t loc, int opt, const char *gmsgid) | 6275 warning_init (location_t loc, int opt, const char *gmsgid) |
6180 { | 6276 { |
6181 char *ofwhat; | 6277 char *ofwhat; |
6182 bool warned; | 6278 bool warned; |
6279 | |
6280 auto_diagnostic_group d; | |
6183 | 6281 |
6184 /* Use the location where a macro was expanded rather than where | 6282 /* Use the location where a macro was expanded rather than where |
6185 it was defined to make sure macros defined in system headers | 6283 it was defined to make sure macros defined in system headers |
6186 but used incorrectly elsewhere are diagnosed. */ | 6284 but used incorrectly elsewhere are diagnosed. */ |
6187 source_location exploc = expansion_point_location_if_in_system_header (loc); | 6285 source_location exploc = expansion_point_location_if_in_system_header (loc); |
6320 #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE) \ | 6418 #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE) \ |
6321 do { \ | 6419 do { \ |
6322 switch (errtype) \ | 6420 switch (errtype) \ |
6323 { \ | 6421 { \ |
6324 case ic_argpass: \ | 6422 case ic_argpass: \ |
6325 if (pedwarn (PLOC, OPT, AR, parmnum, rname)) \ | 6423 { \ |
6326 inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \ | 6424 auto_diagnostic_group d; \ |
6425 if (pedwarn (PLOC, OPT, AR, parmnum, rname)) \ | |
6426 inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \ | |
6427 } \ | |
6327 break; \ | 6428 break; \ |
6328 case ic_assign: \ | 6429 case ic_assign: \ |
6329 pedwarn (LOCATION, OPT, AS); \ | 6430 pedwarn (LOCATION, OPT, AS); \ |
6330 break; \ | 6431 break; \ |
6331 case ic_init: \ | 6432 case ic_init: \ |
6346 #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \ | 6447 #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \ |
6347 do { \ | 6448 do { \ |
6348 switch (errtype) \ | 6449 switch (errtype) \ |
6349 { \ | 6450 { \ |
6350 case ic_argpass: \ | 6451 case ic_argpass: \ |
6351 if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS)) \ | 6452 { \ |
6352 inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \ | 6453 auto_diagnostic_group d; \ |
6454 if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS)) \ | |
6455 inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \ | |
6456 } \ | |
6353 break; \ | 6457 break; \ |
6354 case ic_assign: \ | 6458 case ic_assign: \ |
6355 pedwarn (LOCATION, OPT, AS, QUALS); \ | 6459 pedwarn (LOCATION, OPT, AS, QUALS); \ |
6356 break; \ | 6460 break; \ |
6357 case ic_init: \ | 6461 case ic_init: \ |
6372 #define WARNING_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \ | 6476 #define WARNING_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \ |
6373 do { \ | 6477 do { \ |
6374 switch (errtype) \ | 6478 switch (errtype) \ |
6375 { \ | 6479 { \ |
6376 case ic_argpass: \ | 6480 case ic_argpass: \ |
6377 if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS)) \ | 6481 { \ |
6378 inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \ | 6482 auto_diagnostic_group d; \ |
6483 if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS)) \ | |
6484 inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \ | |
6485 } \ | |
6379 break; \ | 6486 break; \ |
6380 case ic_assign: \ | 6487 case ic_assign: \ |
6381 warning_at (LOCATION, OPT, AS, QUALS); \ | 6488 warning_at (LOCATION, OPT, AS, QUALS); \ |
6382 break; \ | 6489 break; \ |
6383 case ic_init: \ | 6490 case ic_init: \ |
6865 /* If there is a mismatch, do warn. */ | 6972 /* If there is a mismatch, do warn. */ |
6866 else if (warn_pointer_sign) | 6973 else if (warn_pointer_sign) |
6867 switch (errtype) | 6974 switch (errtype) |
6868 { | 6975 { |
6869 case ic_argpass: | 6976 case ic_argpass: |
6870 if (pedwarn (expr_loc, OPT_Wpointer_sign, | 6977 { |
6871 "pointer targets in passing argument %d of " | 6978 auto_diagnostic_group d; |
6872 "%qE differ in signedness", parmnum, rname)) | 6979 range_label_for_type_mismatch rhs_label (rhstype, type); |
6873 inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) | 6980 gcc_rich_location richloc (expr_loc, &rhs_label); |
6874 ? DECL_SOURCE_LOCATION (fundecl) : expr_loc, | 6981 if (pedwarn (&richloc, OPT_Wpointer_sign, |
6875 "expected %qT but argument is of type %qT", | 6982 "pointer targets in passing argument %d of " |
6876 type, rhstype); | 6983 "%qE differ in signedness", parmnum, rname)) |
6984 inform_for_arg (fundecl, expr_loc, parmnum, type, | |
6985 rhstype); | |
6986 } | |
6877 break; | 6987 break; |
6878 case ic_assign: | 6988 case ic_assign: |
6879 pedwarn (location, OPT_Wpointer_sign, | 6989 pedwarn (location, OPT_Wpointer_sign, |
6880 "pointer targets in assignment from %qT to %qT " | 6990 "pointer targets in assignment from %qT to %qT " |
6881 "differ in signedness", rhstype, type); | 6991 "differ in signedness", rhstype, type); |
6922 else if (!objc_ok) | 7032 else if (!objc_ok) |
6923 { | 7033 { |
6924 switch (errtype) | 7034 switch (errtype) |
6925 { | 7035 { |
6926 case ic_argpass: | 7036 case ic_argpass: |
6927 if (pedwarn (expr_loc, OPT_Wincompatible_pointer_types, | 7037 { |
6928 "passing argument %d of %qE from incompatible " | 7038 auto_diagnostic_group d; |
6929 "pointer type", parmnum, rname)) | 7039 range_label_for_type_mismatch rhs_label (rhstype, type); |
6930 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | 7040 gcc_rich_location richloc (expr_loc, &rhs_label); |
7041 if (pedwarn (&richloc, OPT_Wincompatible_pointer_types, | |
7042 "passing argument %d of %qE from incompatible " | |
7043 "pointer type", parmnum, rname)) | |
7044 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | |
7045 } | |
6931 break; | 7046 break; |
6932 case ic_assign: | 7047 case ic_assign: |
6933 pedwarn (location, OPT_Wincompatible_pointer_types, | 7048 pedwarn (location, OPT_Wincompatible_pointer_types, |
6934 "assignment to %qT from incompatible pointer type %qT", | 7049 "assignment to %qT from incompatible pointer type %qT", |
6935 type, rhstype); | 7050 type, rhstype); |
6965 a cast to integer type. */ | 7080 a cast to integer type. */ |
6966 if (!null_pointer_constant) | 7081 if (!null_pointer_constant) |
6967 switch (errtype) | 7082 switch (errtype) |
6968 { | 7083 { |
6969 case ic_argpass: | 7084 case ic_argpass: |
6970 if (pedwarn (expr_loc, OPT_Wint_conversion, | 7085 { |
6971 "passing argument %d of %qE makes pointer from " | 7086 auto_diagnostic_group d; |
6972 "integer without a cast", parmnum, rname)) | 7087 range_label_for_type_mismatch rhs_label (rhstype, type); |
6973 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | 7088 gcc_rich_location richloc (expr_loc, &rhs_label); |
7089 if (pedwarn (&richloc, OPT_Wint_conversion, | |
7090 "passing argument %d of %qE makes pointer from " | |
7091 "integer without a cast", parmnum, rname)) | |
7092 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | |
7093 } | |
6974 break; | 7094 break; |
6975 case ic_assign: | 7095 case ic_assign: |
6976 pedwarn (location, OPT_Wint_conversion, | 7096 pedwarn (location, OPT_Wint_conversion, |
6977 "assignment to %qT from %qT makes pointer from integer " | 7097 "assignment to %qT from %qT makes pointer from integer " |
6978 "without a cast", type, rhstype); | 7098 "without a cast", type, rhstype); |
6996 else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) | 7116 else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) |
6997 { | 7117 { |
6998 switch (errtype) | 7118 switch (errtype) |
6999 { | 7119 { |
7000 case ic_argpass: | 7120 case ic_argpass: |
7001 if (pedwarn (expr_loc, OPT_Wint_conversion, | 7121 { |
7002 "passing argument %d of %qE makes integer from " | 7122 auto_diagnostic_group d; |
7003 "pointer without a cast", parmnum, rname)) | 7123 range_label_for_type_mismatch rhs_label (rhstype, type); |
7004 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | 7124 gcc_rich_location richloc (expr_loc, &rhs_label); |
7125 if (pedwarn (&richloc, OPT_Wint_conversion, | |
7126 "passing argument %d of %qE makes integer from " | |
7127 "pointer without a cast", parmnum, rname)) | |
7128 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | |
7129 } | |
7005 break; | 7130 break; |
7006 case ic_assign: | 7131 case ic_assign: |
7007 pedwarn (location, OPT_Wint_conversion, | 7132 pedwarn (location, OPT_Wint_conversion, |
7008 "assignment to %qT from %qT makes integer from pointer " | 7133 "assignment to %qT from %qT makes integer from pointer " |
7009 "without a cast", type, rhstype); | 7134 "without a cast", type, rhstype); |
7035 } | 7160 } |
7036 | 7161 |
7037 switch (errtype) | 7162 switch (errtype) |
7038 { | 7163 { |
7039 case ic_argpass: | 7164 case ic_argpass: |
7040 error_at (expr_loc, "incompatible type for argument %d of %qE", parmnum, | 7165 { |
7041 rname); | 7166 auto_diagnostic_group d; |
7042 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | 7167 range_label_for_type_mismatch rhs_label (rhstype, type); |
7168 gcc_rich_location richloc (expr_loc, &rhs_label); | |
7169 error_at (&richloc, "incompatible type for argument %d of %qE", parmnum, | |
7170 rname); | |
7171 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); | |
7172 } | |
7043 break; | 7173 break; |
7044 case ic_assign: | 7174 case ic_assign: |
7045 error_at (location, "incompatible types when assigning to type %qT from " | 7175 error_at (location, "incompatible types when assigning to type %qT from " |
7046 "type %qT", type, rhstype); | 7176 "type %qT", type, rhstype); |
7047 break; | 7177 break; |
7317 { | 7447 { |
7318 semantic_type = TREE_TYPE (inside_init); | 7448 semantic_type = TREE_TYPE (inside_init); |
7319 inside_init = TREE_OPERAND (inside_init, 0); | 7449 inside_init = TREE_OPERAND (inside_init, 0); |
7320 } | 7450 } |
7321 inside_init = c_fully_fold (inside_init, require_constant, &maybe_const); | 7451 inside_init = c_fully_fold (inside_init, require_constant, &maybe_const); |
7322 inside_init = decl_constant_value_for_optimization (inside_init); | |
7323 | 7452 |
7324 /* Initialization of an array of chars from a string constant | 7453 /* Initialization of an array of chars from a string constant |
7325 optionally enclosed in braces. */ | 7454 optionally enclosed in braces. */ |
7326 | 7455 |
7327 if (code == ARRAY_TYPE && inside_init | 7456 if (code == ARRAY_TYPE && inside_init |
7382 "from incompatible wide string"); | 7511 "from incompatible wide string"); |
7383 return error_mark_node; | 7512 return error_mark_node; |
7384 } | 7513 } |
7385 } | 7514 } |
7386 | 7515 |
7387 TREE_TYPE (inside_init) = type; | |
7388 if (TYPE_DOMAIN (type) != NULL_TREE | 7516 if (TYPE_DOMAIN (type) != NULL_TREE |
7389 && TYPE_SIZE (type) != NULL_TREE | 7517 && TYPE_SIZE (type) != NULL_TREE |
7390 && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) | 7518 && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) |
7391 { | 7519 { |
7392 unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init); | 7520 unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init); |
7521 unsigned unit = TYPE_PRECISION (typ1) / BITS_PER_UNIT; | |
7393 | 7522 |
7394 /* Subtract the size of a single (possibly wide) character | 7523 /* Subtract the size of a single (possibly wide) character |
7395 because it's ok to ignore the terminating null char | 7524 because it's ok to ignore the terminating null char |
7396 that is counted in the length of the constant. */ | 7525 that is counted in the length of the constant. */ |
7397 if (0 > compare_tree_int (TYPE_SIZE_UNIT (type), | 7526 if (compare_tree_int (TYPE_SIZE_UNIT (type), len - unit) < 0) |
7398 (len | |
7399 - (TYPE_PRECISION (typ1) | |
7400 / BITS_PER_UNIT)))) | |
7401 pedwarn_init (init_loc, 0, | 7527 pedwarn_init (init_loc, 0, |
7402 ("initializer-string for array of chars " | 7528 ("initializer-string for array of chars " |
7403 "is too long")); | 7529 "is too long")); |
7404 else if (warn_cxx_compat | 7530 else if (warn_cxx_compat |
7405 && 0 > compare_tree_int (TYPE_SIZE_UNIT (type), len)) | 7531 && compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0) |
7406 warning_at (init_loc, OPT_Wc___compat, | 7532 warning_at (init_loc, OPT_Wc___compat, |
7407 ("initializer-string for array chars " | 7533 ("initializer-string for array chars " |
7408 "is too long for C++")); | 7534 "is too long for C++")); |
7409 } | 7535 if (compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0) |
7410 | 7536 { |
7537 unsigned HOST_WIDE_INT size | |
7538 = tree_to_uhwi (TYPE_SIZE_UNIT (type)); | |
7539 const char *p = TREE_STRING_POINTER (inside_init); | |
7540 | |
7541 inside_init = build_string (size, p); | |
7542 } | |
7543 } | |
7544 | |
7545 TREE_TYPE (inside_init) = type; | |
7411 return inside_init; | 7546 return inside_init; |
7412 } | 7547 } |
7413 else if (INTEGRAL_TYPE_P (typ1)) | 7548 else if (INTEGRAL_TYPE_P (typ1)) |
7414 { | 7549 { |
7415 error_init (init_loc, "array of inappropriate type initialized " | 7550 error_init (init_loc, "array of inappropriate type initialized " |
7922 if (RECORD_OR_UNION_TYPE_P (constructor_type)) | 8057 if (RECORD_OR_UNION_TYPE_P (constructor_type)) |
7923 { | 8058 { |
7924 constructor_fields = TYPE_FIELDS (constructor_type); | 8059 constructor_fields = TYPE_FIELDS (constructor_type); |
7925 /* Skip any nameless bit fields at the beginning. */ | 8060 /* Skip any nameless bit fields at the beginning. */ |
7926 while (constructor_fields != NULL_TREE | 8061 while (constructor_fields != NULL_TREE |
7927 && DECL_C_BIT_FIELD (constructor_fields) | 8062 && DECL_UNNAMED_BIT_FIELD (constructor_fields)) |
7928 && DECL_NAME (constructor_fields) == NULL_TREE) | |
7929 constructor_fields = DECL_CHAIN (constructor_fields); | 8063 constructor_fields = DECL_CHAIN (constructor_fields); |
7930 | 8064 |
7931 constructor_unfilled_fields = constructor_fields; | 8065 constructor_unfilled_fields = constructor_fields; |
7932 constructor_bit_index = bitsize_zero_node; | 8066 constructor_bit_index = bitsize_zero_node; |
7933 } | 8067 } |
8128 if (RECORD_OR_UNION_TYPE_P (constructor_type)) | 8262 if (RECORD_OR_UNION_TYPE_P (constructor_type)) |
8129 { | 8263 { |
8130 constructor_fields = TYPE_FIELDS (constructor_type); | 8264 constructor_fields = TYPE_FIELDS (constructor_type); |
8131 /* Skip any nameless bit fields at the beginning. */ | 8265 /* Skip any nameless bit fields at the beginning. */ |
8132 while (constructor_fields != NULL_TREE | 8266 while (constructor_fields != NULL_TREE |
8133 && DECL_C_BIT_FIELD (constructor_fields) | 8267 && DECL_UNNAMED_BIT_FIELD (constructor_fields)) |
8134 && DECL_NAME (constructor_fields) == NULL_TREE) | |
8135 constructor_fields = DECL_CHAIN (constructor_fields); | 8268 constructor_fields = DECL_CHAIN (constructor_fields); |
8136 | 8269 |
8137 constructor_unfilled_fields = constructor_fields; | 8270 constructor_unfilled_fields = constructor_fields; |
8138 constructor_bit_index = bitsize_zero_node; | 8271 constructor_bit_index = bitsize_zero_node; |
8139 } | 8272 } |
8282 /* Warn when some structs are initialized with direct aggregation. */ | 8415 /* Warn when some structs are initialized with direct aggregation. */ |
8283 if (!implicit && found_missing_braces && warn_missing_braces | 8416 if (!implicit && found_missing_braces && warn_missing_braces |
8284 && !constructor_zeroinit) | 8417 && !constructor_zeroinit) |
8285 { | 8418 { |
8286 gcc_assert (initializer_stack->missing_brace_richloc); | 8419 gcc_assert (initializer_stack->missing_brace_richloc); |
8287 warning_at_rich_loc (initializer_stack->missing_brace_richloc, | 8420 warning_at (initializer_stack->missing_brace_richloc, |
8288 OPT_Wmissing_braces, | 8421 OPT_Wmissing_braces, |
8289 "missing braces around initializer"); | 8422 "missing braces around initializer"); |
8290 } | 8423 } |
8291 | 8424 |
8292 /* Warn when some struct elements are implicitly initialized to zero. */ | 8425 /* Warn when some struct elements are implicitly initialized to zero. */ |
8293 if (warn_missing_field_initializers | 8426 if (warn_missing_field_initializers |
8294 && constructor_type | 8427 && constructor_type |
8606 tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname); | 8739 tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname); |
8607 if (guessed_id) | 8740 if (guessed_id) |
8608 { | 8741 { |
8609 gcc_rich_location rich_loc (fieldname_loc); | 8742 gcc_rich_location rich_loc (fieldname_loc); |
8610 rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id); | 8743 rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id); |
8611 error_at_rich_loc | 8744 error_at (&rich_loc, |
8612 (&rich_loc, | 8745 "%qT has no member named %qE; did you mean %qE?", |
8613 "%qT has no member named %qE; did you mean %qE?", | 8746 constructor_type, fieldname, guessed_id); |
8614 constructor_type, fieldname, guessed_id); | |
8615 } | 8747 } |
8616 else | 8748 else |
8617 error_at (fieldname_loc, "%qT has no member named %qE", | 8749 error_at (fieldname_loc, "%qT has no member named %qE", |
8618 constructor_type, fieldname); | 8750 constructor_type, fieldname); |
8619 } | 8751 } |
8898 if (TREE_CODE (constructor_type) == RECORD_TYPE) | 9030 if (TREE_CODE (constructor_type) == RECORD_TYPE) |
8899 { | 9031 { |
8900 constructor_unfilled_fields = TYPE_FIELDS (constructor_type); | 9032 constructor_unfilled_fields = TYPE_FIELDS (constructor_type); |
8901 /* Skip any nameless bit fields at the beginning. */ | 9033 /* Skip any nameless bit fields at the beginning. */ |
8902 while (constructor_unfilled_fields != NULL_TREE | 9034 while (constructor_unfilled_fields != NULL_TREE |
8903 && DECL_C_BIT_FIELD (constructor_unfilled_fields) | 9035 && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields)) |
8904 && DECL_NAME (constructor_unfilled_fields) == NULL_TREE) | |
8905 constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields); | 9036 constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields); |
8906 | 9037 |
8907 } | 9038 } |
8908 else if (TREE_CODE (constructor_type) == ARRAY_TYPE) | 9039 else if (TREE_CODE (constructor_type) == ARRAY_TYPE) |
8909 { | 9040 { |
9179 != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field)))) | 9310 != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field)))) |
9180 warning_init (loc, OPT_Wc___compat, | 9311 warning_init (loc, OPT_Wc___compat, |
9181 "enum conversion in initialization is invalid in C++"); | 9312 "enum conversion in initialization is invalid in C++"); |
9182 } | 9313 } |
9183 | 9314 |
9184 /* If this field is empty (and not at the end of structure), | 9315 /* If this field is empty and does not have side effects (and is not at |
9185 don't do anything other than checking the initializer. */ | 9316 the end of structure), don't do anything other than checking the |
9317 initializer. */ | |
9186 if (field | 9318 if (field |
9187 && (TREE_TYPE (field) == error_mark_node | 9319 && (TREE_TYPE (field) == error_mark_node |
9188 || (COMPLETE_TYPE_P (TREE_TYPE (field)) | 9320 || (COMPLETE_TYPE_P (TREE_TYPE (field)) |
9189 && integer_zerop (TYPE_SIZE (TREE_TYPE (field))) | 9321 && integer_zerop (TYPE_SIZE (TREE_TYPE (field))) |
9322 && !TREE_SIDE_EFFECTS (new_value) | |
9190 && (TREE_CODE (constructor_type) == ARRAY_TYPE | 9323 && (TREE_CODE (constructor_type) == ARRAY_TYPE |
9191 || DECL_CHAIN (field))))) | 9324 || DECL_CHAIN (field))))) |
9192 return; | 9325 return; |
9193 | 9326 |
9194 /* Finally, set VALUE to the initializer value digested above. */ | 9327 /* Finally, set VALUE to the initializer value digested above. */ |
9268 constructor_unfilled_fields | 9401 constructor_unfilled_fields |
9269 = DECL_CHAIN (constructor_unfilled_fields); | 9402 = DECL_CHAIN (constructor_unfilled_fields); |
9270 | 9403 |
9271 /* Skip any nameless bit fields. */ | 9404 /* Skip any nameless bit fields. */ |
9272 while (constructor_unfilled_fields != NULL_TREE | 9405 while (constructor_unfilled_fields != NULL_TREE |
9273 && DECL_C_BIT_FIELD (constructor_unfilled_fields) | 9406 && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields)) |
9274 && DECL_NAME (constructor_unfilled_fields) == NULL_TREE) | |
9275 constructor_unfilled_fields = | 9407 constructor_unfilled_fields = |
9276 DECL_CHAIN (constructor_unfilled_fields); | 9408 DECL_CHAIN (constructor_unfilled_fields); |
9277 } | 9409 } |
9278 else if (TREE_CODE (constructor_type) == UNION_TYPE) | 9410 else if (TREE_CODE (constructor_type) == UNION_TYPE) |
9279 constructor_unfilled_fields = NULL_TREE; | 9411 constructor_unfilled_fields = NULL_TREE; |
9280 | 9412 |
9281 /* Now output any pending elements which have become next. */ | 9413 /* Now output any pending elements which have become next. */ |
9282 if (pending) | 9414 if (pending) |
9283 output_pending_init_elements (0, braced_init_obstack); | 9415 output_pending_init_elements (0, braced_init_obstack); |
9416 } | |
9417 | |
9418 /* For two FIELD_DECLs in the same chain, return -1 if field1 | |
9419 comes before field2, 1 if field1 comes after field2 and | |
9420 0 if field1 == field2. */ | |
9421 | |
9422 static int | |
9423 init_field_decl_cmp (tree field1, tree field2) | |
9424 { | |
9425 if (field1 == field2) | |
9426 return 0; | |
9427 | |
9428 tree bitpos1 = bit_position (field1); | |
9429 tree bitpos2 = bit_position (field2); | |
9430 if (tree_int_cst_equal (bitpos1, bitpos2)) | |
9431 { | |
9432 /* If one of the fields has non-zero bitsize, then that | |
9433 field must be the last one in a sequence of zero | |
9434 sized fields, fields after it will have bigger | |
9435 bit_position. */ | |
9436 if (TREE_TYPE (field1) != error_mark_node | |
9437 && COMPLETE_TYPE_P (TREE_TYPE (field1)) | |
9438 && integer_nonzerop (TREE_TYPE (field1))) | |
9439 return 1; | |
9440 if (TREE_TYPE (field2) != error_mark_node | |
9441 && COMPLETE_TYPE_P (TREE_TYPE (field2)) | |
9442 && integer_nonzerop (TREE_TYPE (field2))) | |
9443 return -1; | |
9444 /* Otherwise, fallback to DECL_CHAIN walk to find out | |
9445 which field comes earlier. Walk chains of both | |
9446 fields, so that if field1 and field2 are close to each | |
9447 other in either order, it is found soon even for large | |
9448 sequences of zero sized fields. */ | |
9449 tree f1 = field1, f2 = field2; | |
9450 while (1) | |
9451 { | |
9452 f1 = DECL_CHAIN (f1); | |
9453 f2 = DECL_CHAIN (f2); | |
9454 if (f1 == NULL_TREE) | |
9455 { | |
9456 gcc_assert (f2); | |
9457 return 1; | |
9458 } | |
9459 if (f2 == NULL_TREE) | |
9460 return -1; | |
9461 if (f1 == field2) | |
9462 return -1; | |
9463 if (f2 == field1) | |
9464 return 1; | |
9465 if (!tree_int_cst_equal (bit_position (f1), bitpos1)) | |
9466 return 1; | |
9467 if (!tree_int_cst_equal (bit_position (f2), bitpos1)) | |
9468 return -1; | |
9469 } | |
9470 } | |
9471 else if (tree_int_cst_lt (bitpos1, bitpos2)) | |
9472 return -1; | |
9473 else | |
9474 return 1; | |
9284 } | 9475 } |
9285 | 9476 |
9286 /* Output any pending elements which have become next. | 9477 /* Output any pending elements which have become next. |
9287 As we output elements, constructor_unfilled_{fields,index} | 9478 As we output elements, constructor_unfilled_{fields,index} |
9288 advances, which may cause other elements to become next; | 9479 advances, which may cause other elements to become next; |
9352 } | 9543 } |
9353 } | 9544 } |
9354 } | 9545 } |
9355 else if (RECORD_OR_UNION_TYPE_P (constructor_type)) | 9546 else if (RECORD_OR_UNION_TYPE_P (constructor_type)) |
9356 { | 9547 { |
9357 tree ctor_unfilled_bitpos, elt_bitpos; | |
9358 | |
9359 /* If the current record is complete we are done. */ | 9548 /* If the current record is complete we are done. */ |
9360 if (constructor_unfilled_fields == NULL_TREE) | 9549 if (constructor_unfilled_fields == NULL_TREE) |
9361 break; | 9550 break; |
9362 | 9551 |
9363 ctor_unfilled_bitpos = bit_position (constructor_unfilled_fields); | 9552 int cmp = init_field_decl_cmp (constructor_unfilled_fields, |
9364 elt_bitpos = bit_position (elt->purpose); | 9553 elt->purpose); |
9365 /* We can't compare fields here because there might be empty | 9554 if (cmp == 0) |
9366 fields in between. */ | 9555 output_init_element (input_location, elt->value, elt->origtype, |
9367 if (tree_int_cst_equal (elt_bitpos, ctor_unfilled_bitpos)) | 9556 true, TREE_TYPE (elt->purpose), |
9368 { | 9557 elt->purpose, false, false, |
9369 constructor_unfilled_fields = elt->purpose; | 9558 braced_init_obstack); |
9370 output_init_element (input_location, elt->value, elt->origtype, | 9559 else if (cmp < 0) |
9371 true, TREE_TYPE (elt->purpose), | |
9372 elt->purpose, false, false, | |
9373 braced_init_obstack); | |
9374 } | |
9375 else if (tree_int_cst_lt (ctor_unfilled_bitpos, elt_bitpos)) | |
9376 { | 9560 { |
9377 /* Advance to the next smaller node. */ | 9561 /* Advance to the next smaller node. */ |
9378 if (elt->left) | 9562 if (elt->left) |
9379 elt = elt->left; | 9563 elt = elt->left; |
9380 else | 9564 else |
9396 the parent of it, which is the next bigger node. */ | 9580 the parent of it, which is the next bigger node. */ |
9397 while (elt->parent && elt->parent->right == elt) | 9581 while (elt->parent && elt->parent->right == elt) |
9398 elt = elt->parent; | 9582 elt = elt->parent; |
9399 elt = elt->parent; | 9583 elt = elt->parent; |
9400 if (elt | 9584 if (elt |
9401 && (tree_int_cst_lt (ctor_unfilled_bitpos, | 9585 && init_field_decl_cmp (constructor_unfilled_fields, |
9402 bit_position (elt->purpose)))) | 9586 elt->purpose) < 0) |
9403 { | 9587 { |
9404 next = elt->purpose; | 9588 next = elt->purpose; |
9405 break; | 9589 break; |
9406 } | 9590 } |
9407 } | 9591 } |
9633 if (constructor_unfilled_fields == constructor_fields) | 9817 if (constructor_unfilled_fields == constructor_fields) |
9634 { | 9818 { |
9635 constructor_unfilled_fields = DECL_CHAIN (constructor_fields); | 9819 constructor_unfilled_fields = DECL_CHAIN (constructor_fields); |
9636 /* Skip any nameless bit fields. */ | 9820 /* Skip any nameless bit fields. */ |
9637 while (constructor_unfilled_fields != 0 | 9821 while (constructor_unfilled_fields != 0 |
9638 && DECL_C_BIT_FIELD (constructor_unfilled_fields) | 9822 && (DECL_UNNAMED_BIT_FIELD |
9639 && DECL_NAME (constructor_unfilled_fields) == 0) | 9823 (constructor_unfilled_fields))) |
9640 constructor_unfilled_fields = | 9824 constructor_unfilled_fields = |
9641 DECL_CHAIN (constructor_unfilled_fields); | 9825 DECL_CHAIN (constructor_unfilled_fields); |
9642 } | 9826 } |
9643 } | 9827 } |
9644 | 9828 |
9645 constructor_fields = DECL_CHAIN (constructor_fields); | 9829 constructor_fields = DECL_CHAIN (constructor_fields); |
9646 /* Skip any nameless bit fields at the beginning. */ | 9830 /* Skip any nameless bit fields at the beginning. */ |
9647 while (constructor_fields != NULL_TREE | 9831 while (constructor_fields != NULL_TREE |
9648 && DECL_C_BIT_FIELD (constructor_fields) | 9832 && DECL_UNNAMED_BIT_FIELD (constructor_fields)) |
9649 && DECL_NAME (constructor_fields) == NULL_TREE) | |
9650 constructor_fields = DECL_CHAIN (constructor_fields); | 9833 constructor_fields = DECL_CHAIN (constructor_fields); |
9651 } | 9834 } |
9652 else if (TREE_CODE (constructor_type) == UNION_TYPE) | 9835 else if (TREE_CODE (constructor_type) == UNION_TYPE) |
9653 { | 9836 { |
9654 tree fieldtype; | 9837 tree fieldtype; |
9928 /* Remove output conversions that change the type but not the mode. */ | 10111 /* Remove output conversions that change the type but not the mode. */ |
9929 for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail)) | 10112 for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail)) |
9930 { | 10113 { |
9931 tree output = TREE_VALUE (tail); | 10114 tree output = TREE_VALUE (tail); |
9932 | 10115 |
9933 output = c_fully_fold (output, false, NULL); | 10116 output = c_fully_fold (output, false, NULL, true); |
9934 | 10117 |
9935 /* ??? Really, this should not be here. Users should be using a | 10118 /* ??? Really, this should not be here. Users should be using a |
9936 proper lvalue, dammit. But there's a long history of using casts | 10119 proper lvalue, dammit. But there's a long history of using casts |
9937 in the output operands. In cases like longlong.h, this becomes a | 10120 in the output operands. In cases like longlong.h, this becomes a |
9938 primitive form of typechecking -- if the cast can be removed, then | 10121 primitive form of typechecking -- if the cast can be removed, then |
9986 { | 10169 { |
9987 /* If the operand is going to end up in memory, | 10170 /* If the operand is going to end up in memory, |
9988 mark it addressable. */ | 10171 mark it addressable. */ |
9989 if (!allows_reg && allows_mem) | 10172 if (!allows_reg && allows_mem) |
9990 { | 10173 { |
9991 input = c_fully_fold (input, false, NULL); | 10174 input = c_fully_fold (input, false, NULL, true); |
9992 | 10175 |
9993 /* Strip the nops as we allow this case. FIXME, this really | 10176 /* Strip the nops as we allow this case. FIXME, this really |
9994 should be rejected or made deprecated. */ | 10177 should be rejected or made deprecated. */ |
9995 STRIP_NOPS (input); | 10178 STRIP_NOPS (input); |
9996 if (!c_mark_addressable (input)) | 10179 if (!c_mark_addressable (input)) |
10074 c_finish_return (location_t loc, tree retval, tree origtype) | 10257 c_finish_return (location_t loc, tree retval, tree origtype) |
10075 { | 10258 { |
10076 tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt; | 10259 tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt; |
10077 bool no_warning = false; | 10260 bool no_warning = false; |
10078 bool npc = false; | 10261 bool npc = false; |
10079 size_t rank = 0; | |
10080 | 10262 |
10081 /* Use the expansion point to handle cases such as returning NULL | 10263 /* Use the expansion point to handle cases such as returning NULL |
10082 in a function returning void. */ | 10264 in a function returning void. */ |
10083 source_location xloc = expansion_point_location_if_in_system_header (loc); | 10265 source_location xloc = expansion_point_location_if_in_system_header (loc); |
10084 | 10266 |
10085 if (TREE_THIS_VOLATILE (current_function_decl)) | 10267 if (TREE_THIS_VOLATILE (current_function_decl)) |
10086 warning_at (xloc, 0, | 10268 warning_at (xloc, 0, |
10087 "function declared %<noreturn%> has a %<return%> statement"); | 10269 "function declared %<noreturn%> has a %<return%> statement"); |
10088 | 10270 |
10089 if (flag_cilkplus && contains_array_notation_expr (retval)) | |
10090 { | |
10091 /* Array notations are allowed in a return statement if it is inside a | |
10092 built-in array notation reduction function. */ | |
10093 if (!find_rank (loc, retval, retval, false, &rank)) | |
10094 return error_mark_node; | |
10095 if (rank >= 1) | |
10096 { | |
10097 error_at (loc, "array notation expression cannot be used as a " | |
10098 "return value"); | |
10099 return error_mark_node; | |
10100 } | |
10101 } | |
10102 if (flag_cilkplus && retval && contains_cilk_spawn_stmt (retval)) | |
10103 { | |
10104 error_at (loc, "use of %<_Cilk_spawn%> in a return statement is not " | |
10105 "allowed"); | |
10106 return error_mark_node; | |
10107 } | |
10108 if (retval) | 10271 if (retval) |
10109 { | 10272 { |
10110 tree semantic_type = NULL_TREE; | 10273 tree semantic_type = NULL_TREE; |
10111 npc = null_pointer_constant_p (retval); | 10274 npc = null_pointer_constant_p (retval); |
10112 if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR) | 10275 if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR) |
10120 } | 10283 } |
10121 | 10284 |
10122 if (!retval) | 10285 if (!retval) |
10123 { | 10286 { |
10124 current_function_returns_null = 1; | 10287 current_function_returns_null = 1; |
10125 if ((warn_return_type || flag_isoc99) | 10288 if ((warn_return_type >= 0 || flag_isoc99) |
10126 && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE) | 10289 && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE) |
10127 { | 10290 { |
10128 bool warned_here; | 10291 bool warned_here; |
10129 if (flag_isoc99) | 10292 if (flag_isoc99) |
10130 warned_here = pedwarn | 10293 warned_here = pedwarn |
10131 (loc, 0, | 10294 (loc, warn_return_type >= 0 ? OPT_Wreturn_type : 0, |
10132 "%<return%> with no value, in function returning non-void"); | 10295 "%<return%> with no value, in function returning non-void"); |
10133 else | 10296 else |
10134 warned_here = warning_at | 10297 warned_here = warning_at |
10135 (loc, OPT_Wreturn_type, | 10298 (loc, OPT_Wreturn_type, |
10136 "%<return%> with no value, in function returning non-void"); | 10299 "%<return%> with no value, in function returning non-void"); |
10144 { | 10307 { |
10145 current_function_returns_null = 1; | 10308 current_function_returns_null = 1; |
10146 bool warned_here; | 10309 bool warned_here; |
10147 if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) | 10310 if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) |
10148 warned_here = pedwarn | 10311 warned_here = pedwarn |
10149 (xloc, 0, | 10312 (xloc, warn_return_type >= 0 ? OPT_Wreturn_type : 0, |
10150 "%<return%> with a value, in function returning void"); | 10313 "%<return%> with a value, in function returning void"); |
10151 else | 10314 else |
10152 warned_here = pedwarn | 10315 warned_here = pedwarn |
10153 (xloc, OPT_Wpedantic, "ISO C forbids " | 10316 (xloc, OPT_Wpedantic, "ISO C forbids " |
10154 "%<return%> with expression, in function returning void"); | 10317 "%<return%> with expression, in function returning void"); |
10353 } | 10516 } |
10354 } | 10517 } |
10355 | 10518 |
10356 /* Add this new SWITCH_EXPR to the stack. */ | 10519 /* Add this new SWITCH_EXPR to the stack. */ |
10357 cs = XNEW (struct c_switch); | 10520 cs = XNEW (struct c_switch); |
10358 cs->switch_expr = build3 (SWITCH_EXPR, orig_type, exp, NULL_TREE, NULL_TREE); | 10521 cs->switch_expr = build2 (SWITCH_EXPR, orig_type, exp, NULL_TREE); |
10359 SET_EXPR_LOCATION (cs->switch_expr, switch_loc); | 10522 SET_EXPR_LOCATION (cs->switch_expr, switch_loc); |
10360 cs->orig_type = orig_type; | 10523 cs->orig_type = orig_type; |
10361 cs->cases = splay_tree_new (case_compare, NULL, NULL); | 10524 cs->cases = splay_tree_new (case_compare, NULL, NULL); |
10362 cs->bindings = c_get_switch_bindings (); | 10525 cs->bindings = c_get_switch_bindings (); |
10363 cs->bool_cond_p = bool_cond_p; | 10526 cs->bool_cond_p = bool_cond_p; |
10430 switch_location = EXPR_LOCATION (cs->switch_expr); | 10593 switch_location = EXPR_LOCATION (cs->switch_expr); |
10431 c_do_switch_warnings (cs->cases, switch_location, | 10594 c_do_switch_warnings (cs->cases, switch_location, |
10432 type ? type : TREE_TYPE (cs->switch_expr), | 10595 type ? type : TREE_TYPE (cs->switch_expr), |
10433 SWITCH_COND (cs->switch_expr), | 10596 SWITCH_COND (cs->switch_expr), |
10434 cs->bool_cond_p, cs->outside_range_p); | 10597 cs->bool_cond_p, cs->outside_range_p); |
10598 if (c_switch_covers_all_cases_p (cs->cases, TREE_TYPE (cs->switch_expr))) | |
10599 SWITCH_ALL_CASES_P (cs->switch_expr) = 1; | |
10435 | 10600 |
10436 /* Pop the stack. */ | 10601 /* Pop the stack. */ |
10437 c_switch_stack = cs->next; | 10602 c_switch_stack = cs->next; |
10438 splay_tree_delete (cs->cases); | 10603 splay_tree_delete (cs->cases); |
10439 c_release_switch_bindings (cs->bindings); | 10604 c_release_switch_bindings (cs->bindings); |
10448 c_finish_if_stmt (location_t if_locus, tree cond, tree then_block, | 10613 c_finish_if_stmt (location_t if_locus, tree cond, tree then_block, |
10449 tree else_block) | 10614 tree else_block) |
10450 { | 10615 { |
10451 tree stmt; | 10616 tree stmt; |
10452 | 10617 |
10453 /* If the condition has array notations, then the rank of the then_block and | |
10454 else_block must be either 0 or be equal to the rank of the condition. If | |
10455 the condition does not have array notations then break them up as it is | |
10456 broken up in a normal expression. */ | |
10457 if (flag_cilkplus && contains_array_notation_expr (cond)) | |
10458 { | |
10459 size_t then_rank = 0, cond_rank = 0, else_rank = 0; | |
10460 if (!find_rank (if_locus, cond, cond, true, &cond_rank)) | |
10461 return; | |
10462 if (then_block | |
10463 && !find_rank (if_locus, then_block, then_block, true, &then_rank)) | |
10464 return; | |
10465 if (else_block | |
10466 && !find_rank (if_locus, else_block, else_block, true, &else_rank)) | |
10467 return; | |
10468 if (cond_rank != then_rank && then_rank != 0) | |
10469 { | |
10470 error_at (if_locus, "rank-mismatch between if-statement%'s condition" | |
10471 " and the then-block"); | |
10472 return; | |
10473 } | |
10474 else if (cond_rank != else_rank && else_rank != 0) | |
10475 { | |
10476 error_at (if_locus, "rank-mismatch between if-statement%'s condition" | |
10477 " and the else-block"); | |
10478 return; | |
10479 } | |
10480 } | |
10481 | |
10482 stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block); | 10618 stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block); |
10483 SET_EXPR_LOCATION (stmt, if_locus); | 10619 SET_EXPR_LOCATION (stmt, if_locus); |
10484 add_stmt (stmt); | 10620 add_stmt (stmt); |
10485 } | 10621 } |
10486 | 10622 |
10494 c_finish_loop (location_t start_locus, tree cond, tree incr, tree body, | 10630 c_finish_loop (location_t start_locus, tree cond, tree incr, tree body, |
10495 tree blab, tree clab, bool cond_is_first) | 10631 tree blab, tree clab, bool cond_is_first) |
10496 { | 10632 { |
10497 tree entry = NULL, exit = NULL, t; | 10633 tree entry = NULL, exit = NULL, t; |
10498 | 10634 |
10499 /* In theory could forbid cilk spawn for loop increment expression, | |
10500 but it should work just fine. */ | |
10501 | |
10502 /* If the condition is zero don't generate a loop construct. */ | 10635 /* If the condition is zero don't generate a loop construct. */ |
10503 if (cond && integer_zerop (cond)) | 10636 if (cond && integer_zerop (cond)) |
10504 { | 10637 { |
10505 if (cond_is_first) | 10638 if (cond_is_first) |
10506 { | 10639 { |
10769 last = BIND_EXPR_BODY (body); | 10902 last = BIND_EXPR_BODY (body); |
10770 | 10903 |
10771 continue_searching: | 10904 continue_searching: |
10772 if (TREE_CODE (last) == STATEMENT_LIST) | 10905 if (TREE_CODE (last) == STATEMENT_LIST) |
10773 { | 10906 { |
10774 tree_stmt_iterator i; | 10907 tree_stmt_iterator l = tsi_last (last); |
10908 | |
10909 while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT) | |
10910 tsi_prev (&l); | |
10775 | 10911 |
10776 /* This can happen with degenerate cases like ({ }). No value. */ | 10912 /* This can happen with degenerate cases like ({ }). No value. */ |
10777 if (!TREE_SIDE_EFFECTS (last)) | 10913 if (tsi_end_p (l)) |
10778 return body; | 10914 return body; |
10779 | 10915 |
10780 /* If we're supposed to generate side effects warnings, process | 10916 /* If we're supposed to generate side effects warnings, process |
10781 all of the statements except the last. */ | 10917 all of the statements except the last. */ |
10782 if (warn_unused_value) | 10918 if (warn_unused_value) |
10783 { | 10919 { |
10784 for (i = tsi_start (last); !tsi_one_before_end_p (i); tsi_next (&i)) | 10920 for (tree_stmt_iterator i = tsi_start (last); |
10921 tsi_stmt (i) != tsi_stmt (l); tsi_next (&i)) | |
10785 { | 10922 { |
10786 location_t tloc; | 10923 location_t tloc; |
10787 tree t = tsi_stmt (i); | 10924 tree t = tsi_stmt (i); |
10788 | 10925 |
10789 tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc; | 10926 tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc; |
10790 emit_side_effect_warnings (tloc, t); | 10927 emit_side_effect_warnings (tloc, t); |
10791 } | 10928 } |
10792 } | 10929 } |
10793 else | 10930 last_p = tsi_stmt_ptr (l); |
10794 i = tsi_last (last); | |
10795 last_p = tsi_stmt_ptr (i); | |
10796 last = *last_p; | 10931 last = *last_p; |
10797 } | 10932 } |
10798 | 10933 |
10799 /* If the end of the list is exception related, then the list was split | 10934 /* If the end of the list is exception related, then the list was split |
10800 by a call to push_cleanup. Continue searching. */ | 10935 by a call to push_cleanup. Continue searching. */ |
10809 if (last == error_mark_node) | 10944 if (last == error_mark_node) |
10810 return last; | 10945 return last; |
10811 | 10946 |
10812 /* In the case that the BIND_EXPR is not necessary, return the | 10947 /* In the case that the BIND_EXPR is not necessary, return the |
10813 expression out from inside it. */ | 10948 expression out from inside it. */ |
10814 if (last == BIND_EXPR_BODY (body) | 10949 if ((last == BIND_EXPR_BODY (body) |
10950 /* Skip nested debug stmts. */ | |
10951 || last == expr_first (BIND_EXPR_BODY (body))) | |
10815 && BIND_EXPR_VARS (body) == NULL) | 10952 && BIND_EXPR_VARS (body) == NULL) |
10816 { | 10953 { |
10817 /* Even if this looks constant, do not allow it in a constant | 10954 /* Even if this looks constant, do not allow it in a constant |
10818 expression. */ | 10955 expression. */ |
10819 last = c_wrap_maybe_const (last, true); | 10956 last = c_wrap_maybe_const (last, true); |
10932 tree minus_one_vec = build_minus_one_cst (type); | 11069 tree minus_one_vec = build_minus_one_cst (type); |
10933 tree cmp_type = build_same_sized_truth_vector_type (type); | 11070 tree cmp_type = build_same_sized_truth_vector_type (type); |
10934 tree cmp = build2 (code, cmp_type, arg0, arg1); | 11071 tree cmp = build2 (code, cmp_type, arg0, arg1); |
10935 return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); | 11072 return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); |
10936 } | 11073 } |
11074 | |
11075 /* Subclass of range_label for labelling the type of EXPR when reporting | |
11076 a type mismatch between EXPR and OTHER_EXPR. | |
11077 Either or both of EXPR and OTHER_EXPR could be NULL. */ | |
11078 | |
11079 class maybe_range_label_for_tree_type_mismatch : public range_label | |
11080 { | |
11081 public: | |
11082 maybe_range_label_for_tree_type_mismatch (tree expr, tree other_expr) | |
11083 : m_expr (expr), m_other_expr (other_expr) | |
11084 { | |
11085 } | |
11086 | |
11087 label_text get_text (unsigned range_idx) const FINAL OVERRIDE | |
11088 { | |
11089 if (m_expr == NULL_TREE | |
11090 || !EXPR_P (m_expr)) | |
11091 return label_text (NULL, false); | |
11092 tree expr_type = TREE_TYPE (m_expr); | |
11093 | |
11094 tree other_type = NULL_TREE; | |
11095 if (m_other_expr && EXPR_P (m_other_expr)) | |
11096 other_type = TREE_TYPE (m_other_expr); | |
11097 | |
11098 range_label_for_type_mismatch inner (expr_type, other_type); | |
11099 return inner.get_text (range_idx); | |
11100 } | |
11101 | |
11102 private: | |
11103 tree m_expr; | |
11104 tree m_other_expr; | |
11105 }; | |
10937 | 11106 |
10938 /* Build a binary-operation expression without default conversions. | 11107 /* Build a binary-operation expression without default conversions. |
10939 CODE is the kind of expression to build. | 11108 CODE is the kind of expression to build. |
10940 LOCATION is the operator's location. | 11109 LOCATION is the operator's location. |
10941 This function differs from `build' in several ways: | 11110 This function differs from `build' in several ways: |
11060 { | 11229 { |
11061 op0 = default_conversion (op0); | 11230 op0 = default_conversion (op0); |
11062 op1 = default_conversion (op1); | 11231 op1 = default_conversion (op1); |
11063 } | 11232 } |
11064 | 11233 |
11065 /* When Cilk Plus is enabled and there are array notations inside op0, then | 11234 orig_type0 = type0 = TREE_TYPE (op0); |
11066 we check to see if there are builtin array notation functions. If | 11235 |
11067 so, then we take on the type of the array notation inside it. */ | 11236 orig_type1 = type1 = TREE_TYPE (op1); |
11068 if (flag_cilkplus && contains_array_notation_expr (op0)) | |
11069 orig_type0 = type0 = find_correct_array_notation_type (op0); | |
11070 else | |
11071 orig_type0 = type0 = TREE_TYPE (op0); | |
11072 | |
11073 if (flag_cilkplus && contains_array_notation_expr (op1)) | |
11074 orig_type1 = type1 = find_correct_array_notation_type (op1); | |
11075 else | |
11076 orig_type1 = type1 = TREE_TYPE (op1); | |
11077 | 11237 |
11078 /* The expression codes of the data types of the arguments tell us | 11238 /* The expression codes of the data types of the arguments tell us |
11079 whether the arguments are integers, floating, pointers, etc. */ | 11239 whether the arguments are integers, floating, pointers, etc. */ |
11080 code0 = TREE_CODE (type0); | 11240 code0 = TREE_CODE (type0); |
11081 code1 = TREE_CODE (type1); | 11241 code1 = TREE_CODE (type1); |
11115 case FLOOR_DIV_EXPR: | 11275 case FLOOR_DIV_EXPR: |
11116 case ROUND_DIV_EXPR: | 11276 case ROUND_DIV_EXPR: |
11117 case EXACT_DIV_EXPR: | 11277 case EXACT_DIV_EXPR: |
11118 may_need_excess_precision = true; | 11278 may_need_excess_precision = true; |
11119 break; | 11279 break; |
11280 | |
11281 case EQ_EXPR: | |
11282 case NE_EXPR: | |
11283 case LE_EXPR: | |
11284 case GE_EXPR: | |
11285 case LT_EXPR: | |
11286 case GT_EXPR: | |
11287 /* Excess precision for implicit conversions of integers to | |
11288 floating point in C11 and later. */ | |
11289 may_need_excess_precision = (flag_isoc11 | |
11290 && (ANY_INTEGRAL_TYPE_P (type0) | |
11291 || ANY_INTEGRAL_TYPE_P (type1))); | |
11292 break; | |
11293 | |
11120 default: | 11294 default: |
11121 may_need_excess_precision = false; | 11295 may_need_excess_precision = false; |
11122 break; | 11296 break; |
11123 } | 11297 } |
11124 if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR) | 11298 if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR) |
11214 /* Subtraction of two similar pointers. | 11388 /* Subtraction of two similar pointers. |
11215 We must subtract them as integers, then divide by object size. */ | 11389 We must subtract them as integers, then divide by object size. */ |
11216 if (code0 == POINTER_TYPE && code1 == POINTER_TYPE | 11390 if (code0 == POINTER_TYPE && code1 == POINTER_TYPE |
11217 && comp_target_types (location, type0, type1)) | 11391 && comp_target_types (location, type0, type1)) |
11218 { | 11392 { |
11219 ret = pointer_diff (location, op0, op1); | 11393 ret = pointer_diff (location, op0, op1, &instrument_expr); |
11220 goto return_build_binary_op; | 11394 goto return_build_binary_op; |
11221 } | 11395 } |
11222 /* Handle pointer minus int. Just like pointer plus int. */ | 11396 /* Handle pointer minus int. Just like pointer plus int. */ |
11223 else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) | 11397 else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) |
11224 { | 11398 { |
11369 | 11543 |
11370 case RSHIFT_EXPR: | 11544 case RSHIFT_EXPR: |
11371 if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE | 11545 if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE |
11372 && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE | 11546 && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE |
11373 && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE | 11547 && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE |
11374 && TYPE_VECTOR_SUBPARTS (type0) == TYPE_VECTOR_SUBPARTS (type1)) | 11548 && known_eq (TYPE_VECTOR_SUBPARTS (type0), |
11549 TYPE_VECTOR_SUBPARTS (type1))) | |
11375 { | 11550 { |
11376 result_type = type0; | 11551 result_type = type0; |
11377 converted = 1; | 11552 converted = 1; |
11378 } | 11553 } |
11379 else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE | 11554 else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE |
11380 || code0 == VECTOR_TYPE) | 11555 || (code0 == VECTOR_TYPE |
11556 && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE)) | |
11381 && code1 == INTEGER_TYPE) | 11557 && code1 == INTEGER_TYPE) |
11382 { | 11558 { |
11383 doing_shift = true; | 11559 doing_shift = true; |
11384 if (TREE_CODE (op1) == INTEGER_CST) | 11560 if (TREE_CODE (op1) == INTEGER_CST) |
11385 { | 11561 { |
11426 | 11602 |
11427 case LSHIFT_EXPR: | 11603 case LSHIFT_EXPR: |
11428 if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE | 11604 if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE |
11429 && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE | 11605 && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE |
11430 && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE | 11606 && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE |
11431 && TYPE_VECTOR_SUBPARTS (type0) == TYPE_VECTOR_SUBPARTS (type1)) | 11607 && known_eq (TYPE_VECTOR_SUBPARTS (type0), |
11608 TYPE_VECTOR_SUBPARTS (type1))) | |
11432 { | 11609 { |
11433 result_type = type0; | 11610 result_type = type0; |
11434 converted = 1; | 11611 converted = 1; |
11435 } | 11612 } |
11436 else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE | 11613 else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE |
11437 || code0 == VECTOR_TYPE) | 11614 || (code0 == VECTOR_TYPE |
11615 && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE)) | |
11438 && code1 == INTEGER_TYPE) | 11616 && code1 == INTEGER_TYPE) |
11439 { | 11617 { |
11440 doing_shift = true; | 11618 doing_shift = true; |
11441 if (TREE_CODE (op0) == INTEGER_CST | 11619 if (TREE_CODE (op0) == INTEGER_CST |
11442 && tree_int_cst_sgn (op0) < 0) | 11620 && tree_int_cst_sgn (op0) < 0) |
11500 error_at (location, "comparing vectors with different " | 11678 error_at (location, "comparing vectors with different " |
11501 "element types"); | 11679 "element types"); |
11502 return error_mark_node; | 11680 return error_mark_node; |
11503 } | 11681 } |
11504 | 11682 |
11505 if (TYPE_VECTOR_SUBPARTS (type0) != TYPE_VECTOR_SUBPARTS (type1)) | 11683 if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0), |
11684 TYPE_VECTOR_SUBPARTS (type1))) | |
11506 { | 11685 { |
11507 error_at (location, "comparing vectors with different " | 11686 error_at (location, "comparing vectors with different " |
11508 "number of elements"); | 11687 "number of elements"); |
11509 return error_mark_node; | 11688 return error_mark_node; |
11510 } | 11689 } |
11525 | 11704 |
11526 /* Always construct signed integer vector type. */ | 11705 /* Always construct signed integer vector type. */ |
11527 intt = c_common_type_for_size (GET_MODE_BITSIZE | 11706 intt = c_common_type_for_size (GET_MODE_BITSIZE |
11528 (SCALAR_TYPE_MODE | 11707 (SCALAR_TYPE_MODE |
11529 (TREE_TYPE (type0))), 0); | 11708 (TREE_TYPE (type0))), 0); |
11709 if (!intt) | |
11710 { | |
11711 error_at (location, "could not find an integer type " | |
11712 "of the same size as %qT", | |
11713 TREE_TYPE (type0)); | |
11714 return error_mark_node; | |
11715 } | |
11530 result_type = build_opaque_vector_type (intt, | 11716 result_type = build_opaque_vector_type (intt, |
11531 TYPE_VECTOR_SUBPARTS (type0)); | 11717 TYPE_VECTOR_SUBPARTS (type0)); |
11532 converted = 1; | 11718 converted = 1; |
11533 ret = build_vec_cmp (resultcode, result_type, op0, op1); | 11719 ret = build_vec_cmp (resultcode, result_type, op0, op1); |
11534 goto return_build_binary_op; | 11720 goto return_build_binary_op; |
11660 error_at (location, "comparing vectors with different " | 11846 error_at (location, "comparing vectors with different " |
11661 "element types"); | 11847 "element types"); |
11662 return error_mark_node; | 11848 return error_mark_node; |
11663 } | 11849 } |
11664 | 11850 |
11665 if (TYPE_VECTOR_SUBPARTS (type0) != TYPE_VECTOR_SUBPARTS (type1)) | 11851 if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0), |
11852 TYPE_VECTOR_SUBPARTS (type1))) | |
11666 { | 11853 { |
11667 error_at (location, "comparing vectors with different " | 11854 error_at (location, "comparing vectors with different " |
11668 "number of elements"); | 11855 "number of elements"); |
11669 return error_mark_node; | 11856 return error_mark_node; |
11670 } | 11857 } |
11685 | 11872 |
11686 /* Always construct signed integer vector type. */ | 11873 /* Always construct signed integer vector type. */ |
11687 intt = c_common_type_for_size (GET_MODE_BITSIZE | 11874 intt = c_common_type_for_size (GET_MODE_BITSIZE |
11688 (SCALAR_TYPE_MODE | 11875 (SCALAR_TYPE_MODE |
11689 (TREE_TYPE (type0))), 0); | 11876 (TREE_TYPE (type0))), 0); |
11877 if (!intt) | |
11878 { | |
11879 error_at (location, "could not find an integer type " | |
11880 "of the same size as %qT", | |
11881 TREE_TYPE (type0)); | |
11882 return error_mark_node; | |
11883 } | |
11690 result_type = build_opaque_vector_type (intt, | 11884 result_type = build_opaque_vector_type (intt, |
11691 TYPE_VECTOR_SUBPARTS (type0)); | 11885 TYPE_VECTOR_SUBPARTS (type0)); |
11692 converted = 1; | 11886 converted = 1; |
11693 ret = build_vec_cmp (resultcode, result_type, op0, op1); | 11887 ret = build_vec_cmp (resultcode, result_type, op0, op1); |
11694 goto return_build_binary_op; | 11888 goto return_build_binary_op; |
11764 else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) | 11958 else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) |
11765 { | 11959 { |
11766 result_type = type1; | 11960 result_type = type1; |
11767 pedwarn (location, 0, "comparison between pointer and integer"); | 11961 pedwarn (location, 0, "comparison between pointer and integer"); |
11768 } | 11962 } |
11963 | |
11964 if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE) | |
11965 && sanitize_flags_p (SANITIZE_POINTER_COMPARE)) | |
11966 { | |
11967 op0 = save_expr (op0); | |
11968 op1 = save_expr (op1); | |
11969 | |
11970 tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE); | |
11971 instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1); | |
11972 } | |
11973 | |
11769 if ((TREE_CODE (TREE_TYPE (orig_op0)) == BOOLEAN_TYPE | 11974 if ((TREE_CODE (TREE_TYPE (orig_op0)) == BOOLEAN_TYPE |
11770 || truth_value_p (TREE_CODE (orig_op0))) | 11975 || truth_value_p (TREE_CODE (orig_op0))) |
11771 ^ (TREE_CODE (TREE_TYPE (orig_op1)) == BOOLEAN_TYPE | 11976 ^ (TREE_CODE (TREE_TYPE (orig_op1)) == BOOLEAN_TYPE |
11772 || truth_value_p (TREE_CODE (orig_op1)))) | 11977 || truth_value_p (TREE_CODE (orig_op1)))) |
11773 maybe_warn_bool_compare (location, code, orig_op0, orig_op1); | 11978 maybe_warn_bool_compare (location, code, orig_op0, orig_op1); |
11783 if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE | 11988 if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE |
11784 && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1)) | 11989 && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1)) |
11785 || !vector_types_compatible_elements_p (type0, type1))) | 11990 || !vector_types_compatible_elements_p (type0, type1))) |
11786 { | 11991 { |
11787 gcc_rich_location richloc (location); | 11992 gcc_rich_location richloc (location); |
11788 richloc.maybe_add_expr (orig_op0); | 11993 maybe_range_label_for_tree_type_mismatch |
11789 richloc.maybe_add_expr (orig_op1); | 11994 label_for_op0 (orig_op0, orig_op1), |
11995 label_for_op1 (orig_op1, orig_op0); | |
11996 richloc.maybe_add_expr (orig_op0, &label_for_op0); | |
11997 richloc.maybe_add_expr (orig_op1, &label_for_op1); | |
11790 binary_op_error (&richloc, code, type0, type1); | 11998 binary_op_error (&richloc, code, type0, type1); |
11791 return error_mark_node; | 11999 return error_mark_node; |
11792 } | 12000 } |
11793 | 12001 |
11794 if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE | 12002 if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE |
12025 otherwise, it will be given type RESULT_TYPE. */ | 12233 otherwise, it will be given type RESULT_TYPE. */ |
12026 | 12234 |
12027 if (!result_type) | 12235 if (!result_type) |
12028 { | 12236 { |
12029 gcc_rich_location richloc (location); | 12237 gcc_rich_location richloc (location); |
12030 richloc.maybe_add_expr (orig_op0); | 12238 maybe_range_label_for_tree_type_mismatch |
12031 richloc.maybe_add_expr (orig_op1); | 12239 label_for_op0 (orig_op0, orig_op1), |
12240 label_for_op1 (orig_op1, orig_op0); | |
12241 richloc.maybe_add_expr (orig_op0, &label_for_op0); | |
12242 richloc.maybe_add_expr (orig_op1, &label_for_op1); | |
12032 binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1)); | 12243 binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1)); |
12033 return error_mark_node; | 12244 return error_mark_node; |
12034 } | 12245 } |
12035 | 12246 |
12036 if (build_type == NULL_TREE) | 12247 if (build_type == NULL_TREE) |
12752 } | 12963 } |
12753 t = TREE_CHAIN (t); | 12964 t = TREE_CHAIN (t); |
12754 } | 12965 } |
12755 if (tem) | 12966 if (tem) |
12756 first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first); | 12967 first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first); |
12757 first = c_fully_fold (first, false, NULL); | 12968 first = c_fully_fold (first, false, NULL, true); |
12758 OMP_CLAUSE_DECL (c) = first; | 12969 OMP_CLAUSE_DECL (c) = first; |
12759 } | 12970 } |
12760 else | 12971 else |
12761 { | 12972 { |
12762 unsigned int num = types.length (), i; | 12973 unsigned int num = types.length (), i; |
13315 error_at (OMP_CLAUSE_LOCATION (c), | 13526 error_at (OMP_CLAUSE_LOCATION (c), |
13316 "modifier should not be specified in %<linear%> " | 13527 "modifier should not be specified in %<linear%> " |
13317 "clause on %<simd%> or %<for%> constructs"); | 13528 "clause on %<simd%> or %<for%> constructs"); |
13318 OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT; | 13529 OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT; |
13319 } | 13530 } |
13320 if (ort & C_ORT_CILK) | 13531 if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) |
13321 { | 13532 && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) |
13322 if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) | 13533 { |
13323 && !SCALAR_FLOAT_TYPE_P (TREE_TYPE (t)) | 13534 error_at (OMP_CLAUSE_LOCATION (c), |
13324 && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) | 13535 "linear clause applied to non-integral non-pointer " |
13325 { | 13536 "variable with type %qT", TREE_TYPE (t)); |
13326 error_at (OMP_CLAUSE_LOCATION (c), | 13537 remove = true; |
13327 "linear clause applied to non-integral, " | 13538 break; |
13328 "non-floating, non-pointer variable with type %qT", | 13539 } |
13329 TREE_TYPE (t)); | 13540 if (TYPE_ATOMIC (TREE_TYPE (t))) |
13330 remove = true; | 13541 { |
13331 break; | 13542 error_at (OMP_CLAUSE_LOCATION (c), |
13332 } | 13543 "%<_Atomic%> %qD in %<linear%> clause", t); |
13333 } | 13544 remove = true; |
13334 else | 13545 break; |
13335 { | |
13336 if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) | |
13337 && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) | |
13338 { | |
13339 error_at (OMP_CLAUSE_LOCATION (c), | |
13340 "linear clause applied to non-integral non-pointer " | |
13341 "variable with type %qT", TREE_TYPE (t)); | |
13342 remove = true; | |
13343 break; | |
13344 } | |
13345 if (TYPE_ATOMIC (TREE_TYPE (t))) | |
13346 { | |
13347 error_at (OMP_CLAUSE_LOCATION (c), | |
13348 "%<_Atomic%> %qD in %<linear%> clause", t); | |
13349 remove = true; | |
13350 break; | |
13351 } | |
13352 } | 13546 } |
13353 if (ort == C_ORT_OMP_DECLARE_SIMD) | 13547 if (ort == C_ORT_OMP_DECLARE_SIMD) |
13354 { | 13548 { |
13355 tree s = OMP_CLAUSE_LINEAR_STEP (c); | 13549 tree s = OMP_CLAUSE_LINEAR_STEP (c); |
13356 if (TREE_CODE (s) == PARM_DECL) | 13550 if (TREE_CODE (s) == PARM_DECL) |
13878 case OMP_CLAUSE_NOGROUP: | 14072 case OMP_CLAUSE_NOGROUP: |
13879 case OMP_CLAUSE_THREADS: | 14073 case OMP_CLAUSE_THREADS: |
13880 case OMP_CLAUSE_SIMD: | 14074 case OMP_CLAUSE_SIMD: |
13881 case OMP_CLAUSE_HINT: | 14075 case OMP_CLAUSE_HINT: |
13882 case OMP_CLAUSE_DEFAULTMAP: | 14076 case OMP_CLAUSE_DEFAULTMAP: |
13883 case OMP_CLAUSE__CILK_FOR_COUNT_: | |
13884 case OMP_CLAUSE_NUM_GANGS: | 14077 case OMP_CLAUSE_NUM_GANGS: |
13885 case OMP_CLAUSE_NUM_WORKERS: | 14078 case OMP_CLAUSE_NUM_WORKERS: |
13886 case OMP_CLAUSE_VECTOR_LENGTH: | 14079 case OMP_CLAUSE_VECTOR_LENGTH: |
13887 case OMP_CLAUSE_ASYNC: | 14080 case OMP_CLAUSE_ASYNC: |
13888 case OMP_CLAUSE_WAIT: | 14081 case OMP_CLAUSE_WAIT: |
13891 case OMP_CLAUSE_SEQ: | 14084 case OMP_CLAUSE_SEQ: |
13892 case OMP_CLAUSE_GANG: | 14085 case OMP_CLAUSE_GANG: |
13893 case OMP_CLAUSE_WORKER: | 14086 case OMP_CLAUSE_WORKER: |
13894 case OMP_CLAUSE_VECTOR: | 14087 case OMP_CLAUSE_VECTOR: |
13895 case OMP_CLAUSE_TILE: | 14088 case OMP_CLAUSE_TILE: |
14089 case OMP_CLAUSE_IF_PRESENT: | |
14090 case OMP_CLAUSE_FINALIZE: | |
13896 pc = &OMP_CLAUSE_CHAIN (c); | 14091 pc = &OMP_CLAUSE_CHAIN (c); |
13897 continue; | 14092 continue; |
13898 | 14093 |
13899 case OMP_CLAUSE_SCHEDULE: | 14094 case OMP_CLAUSE_SCHEDULE: |
13900 if (OMP_CLAUSE_SCHEDULE_KIND (c) & OMP_CLAUSE_SCHEDULE_NONMONOTONIC) | 14095 if (OMP_CLAUSE_SCHEDULE_KIND (c) & OMP_CLAUSE_SCHEDULE_NONMONOTONIC) |
14430 } | 14625 } |
14431 /* We can get here with --disable-checking. */ | 14626 /* We can get here with --disable-checking. */ |
14432 return false; | 14627 return false; |
14433 } | 14628 } |
14434 | 14629 |
14435 /* Inserts "cleanup" functions after the function-body of FNDECL. FNDECL is a | |
14436 spawn-helper and BODY is the newly created body for FNDECL. */ | |
14437 | |
14438 void | |
14439 cilk_install_body_with_frame_cleanup (tree fndecl, tree body, void *w) | |
14440 { | |
14441 tree list = alloc_stmt_list (); | |
14442 tree frame = make_cilk_frame (fndecl); | |
14443 tree dtor = create_cilk_function_exit (frame, false, true); | |
14444 add_local_decl (cfun, frame); | |
14445 | |
14446 DECL_SAVED_TREE (fndecl) = list; | |
14447 | |
14448 tree body_list = alloc_stmt_list (); | |
14449 cilk_outline (fndecl, &body, (struct wrapper_data *) w); | |
14450 body = fold_build_cleanup_point_expr (void_type_node, body); | |
14451 | |
14452 append_to_statement_list (body, &body_list); | |
14453 append_to_statement_list (build_stmt (EXPR_LOCATION (body), TRY_FINALLY_EXPR, | |
14454 body_list, dtor), &list); | |
14455 } | |
14456 | |
14457 /* Returns true when the function declaration FNDECL is implicit, | 14630 /* Returns true when the function declaration FNDECL is implicit, |
14458 introduced as a result of a call to an otherwise undeclared | 14631 introduced as a result of a call to an otherwise undeclared |
14459 function, and false otherwise. */ | 14632 function, and false otherwise. */ |
14460 | 14633 |
14461 bool | 14634 bool |