Mercurial > hg > CbC > CbC_gcc
comparison gcc/c/c-parser.c @ 132:d34655255c78
update gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 10:21:07 +0900 |
parents | 5d30d517ebed 84e7813d76e9 |
children | 4e440907fcbf |
comparison
equal
deleted
inserted
replaced
130:e108057fa461 | 132:d34655255c78 |
---|---|
1 /* Parser for C and Objective-C. | 1 /* Parser for C and Objective-C. |
2 Copyright (C) 1987-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1987-2018 Free Software Foundation, Inc. |
3 | 3 |
4 Parser actions based on the old Bison parser; structure somewhat | 4 Parser actions based on the old Bison parser; structure somewhat |
5 influenced by and fragments based on the C++ parser. | 5 influenced by and fragments based on the C++ parser. |
6 | 6 |
7 This file is part of GCC. | 7 This file is part of GCC. |
34 | 34 |
35 Make more diagnostics in the front end generally take an explicit | 35 Make more diagnostics in the front end generally take an explicit |
36 location rather than implicitly using input_location. */ | 36 location rather than implicitly using input_location. */ |
37 | 37 |
38 #include "config.h" | 38 #include "config.h" |
39 #define INCLUDE_UNIQUE_PTR | |
39 #include "system.h" | 40 #include "system.h" |
40 #include "coretypes.h" | 41 #include "coretypes.h" |
41 #include "target.h" | 42 #include "target.h" |
42 #include "function.h" | 43 #include "function.h" |
43 #include "c-tree.h" | 44 #include "c-tree.h" |
63 #include "c-parser.h" | 64 #include "c-parser.h" |
64 #include "gimple-parser.h" | 65 #include "gimple-parser.h" |
65 #include "read-rtl-function.h" | 66 #include "read-rtl-function.h" |
66 #include "run-rtl-passes.h" | 67 #include "run-rtl-passes.h" |
67 #include "intl.h" | 68 #include "intl.h" |
69 #include "c-family/name-hint.h" | |
70 #include "tree-iterator.h" | |
68 #ifndef noCbC | 71 #ifndef noCbC |
69 #include "cbc-tree.h" | 72 #include "cbc-tree.h" |
70 #endif | 73 #endif |
71 | 74 |
72 /* We need to walk over decls with incomplete struct/union/enum types | 75 /* We need to walk over decls with incomplete struct/union/enum types |
201 is 1 | TM_STMT_ATTR_*. */ | 204 is 1 | TM_STMT_ATTR_*. */ |
202 unsigned int in_transaction : 4; | 205 unsigned int in_transaction : 4; |
203 /* True if we are in a context where the Objective-C "Property attribute" | 206 /* True if we are in a context where the Objective-C "Property attribute" |
204 keywords are valid. */ | 207 keywords are valid. */ |
205 BOOL_BITFIELD objc_property_attr_context : 1; | 208 BOOL_BITFIELD objc_property_attr_context : 1; |
206 | |
207 /* Cilk Plus specific parser/lexer information. */ | |
208 | |
209 /* Buffer to hold all the tokens from parsing the vector attribute for the | |
210 SIMD-enabled functions (formerly known as elemental functions). */ | |
211 vec <c_token, va_gc> *cilk_simd_fn_tokens; | |
212 | 209 |
213 /* Location of the last consumed token. */ | 210 /* Location of the last consumed token. */ |
214 location_t last_token_location; | 211 location_t last_token_location; |
215 }; | 212 }; |
216 | 213 |
508 case RID_ATTRIBUTE: | 505 case RID_ATTRIBUTE: |
509 case RID_FRACT: | 506 case RID_FRACT: |
510 case RID_ACCUM: | 507 case RID_ACCUM: |
511 case RID_SAT: | 508 case RID_SAT: |
512 case RID_AUTO_TYPE: | 509 case RID_AUTO_TYPE: |
510 case RID_ALIGNAS: | |
513 #ifndef noCbC | 511 #ifndef noCbC |
514 case RID_CbC_CODE: | 512 case RID_CbC_CODE: |
515 #endif | 513 #endif |
516 return true; | 514 return true; |
517 default: | 515 default: |
1336 | ((warn_c90_c99_compat == 1) << 7) | 1334 | ((warn_c90_c99_compat == 1) << 7) |
1337 | ((warn_c90_c99_compat == -1) << 8) | 1335 | ((warn_c90_c99_compat == -1) << 8) |
1338 /* Similarly for warn_c99_c11_compat. */ | 1336 /* Similarly for warn_c99_c11_compat. */ |
1339 | ((warn_c99_c11_compat == 1) << 9) | 1337 | ((warn_c99_c11_compat == 1) << 9) |
1340 | ((warn_c99_c11_compat == -1) << 10) | 1338 | ((warn_c99_c11_compat == -1) << 10) |
1339 /* Similarly for warn_c11_c2x_compat. */ | |
1340 | ((warn_c11_c2x_compat == 1) << 11) | |
1341 | ((warn_c11_c2x_compat == -1) << 12) | |
1341 ); | 1342 ); |
1342 cpp_opts->cpp_pedantic = pedantic = 0; | 1343 cpp_opts->cpp_pedantic = pedantic = 0; |
1343 warn_pointer_arith = 0; | 1344 warn_pointer_arith = 0; |
1344 cpp_opts->cpp_warn_traditional = warn_traditional = 0; | 1345 cpp_opts->cpp_warn_traditional = warn_traditional = 0; |
1345 flag_iso = 0; | 1346 flag_iso = 0; |
1346 cpp_opts->cpp_warn_long_long = warn_long_long = 0; | 1347 cpp_opts->cpp_warn_long_long = warn_long_long = 0; |
1347 warn_cxx_compat = 0; | 1348 warn_cxx_compat = 0; |
1348 warn_overlength_strings = 0; | 1349 warn_overlength_strings = 0; |
1349 warn_c90_c99_compat = 0; | 1350 warn_c90_c99_compat = 0; |
1350 warn_c99_c11_compat = 0; | 1351 warn_c99_c11_compat = 0; |
1352 warn_c11_c2x_compat = 0; | |
1351 return ret; | 1353 return ret; |
1352 } | 1354 } |
1353 | 1355 |
1354 /* Restore the warning flags which are controlled by __extension__. | 1356 /* Restore the warning flags which are controlled by __extension__. |
1355 FLAGS is the return value from disable_extension_diagnostics. */ | 1357 FLAGS is the return value from disable_extension_diagnostics. */ |
1365 warn_cxx_compat = (flags >> 5) & 1; | 1367 warn_cxx_compat = (flags >> 5) & 1; |
1366 warn_overlength_strings = (flags >> 6) & 1; | 1368 warn_overlength_strings = (flags >> 6) & 1; |
1367 /* See above for why is this needed. */ | 1369 /* See above for why is this needed. */ |
1368 warn_c90_c99_compat = (flags >> 7) & 1 ? 1 : ((flags >> 8) & 1 ? -1 : 0); | 1370 warn_c90_c99_compat = (flags >> 7) & 1 ? 1 : ((flags >> 8) & 1 ? -1 : 0); |
1369 warn_c99_c11_compat = (flags >> 9) & 1 ? 1 : ((flags >> 10) & 1 ? -1 : 0); | 1371 warn_c99_c11_compat = (flags >> 9) & 1 ? 1 : ((flags >> 10) & 1 ? -1 : 0); |
1372 warn_c11_c2x_compat = (flags >> 11) & 1 ? 1 : ((flags >> 12) & 1 ? -1 : 0); | |
1370 } | 1373 } |
1371 | 1374 |
1372 /* Helper data structure for parsing #pragma acc routine. */ | 1375 /* Helper data structure for parsing #pragma acc routine. */ |
1373 struct oacc_routine_data { | 1376 struct oacc_routine_data { |
1374 bool error_seen; /* Set if error has been reported. */ | 1377 bool error_seen; /* Set if error has been reported. */ |
1415 vec<tree> * = NULL); | 1418 vec<tree> * = NULL); |
1416 static tree c_parser_c99_block_statement (c_parser *, bool *, | 1419 static tree c_parser_c99_block_statement (c_parser *, bool *, |
1417 location_t * = NULL); | 1420 location_t * = NULL); |
1418 static void c_parser_if_statement (c_parser *, bool *, vec<tree> *); | 1421 static void c_parser_if_statement (c_parser *, bool *, vec<tree> *); |
1419 static void c_parser_switch_statement (c_parser *, bool *); | 1422 static void c_parser_switch_statement (c_parser *, bool *); |
1420 static void c_parser_while_statement (c_parser *, bool, bool *); | 1423 static void c_parser_while_statement (c_parser *, bool, unsigned short, bool *); |
1421 static void c_parser_do_statement (c_parser *, bool); | 1424 static void c_parser_do_statement (c_parser *, bool, unsigned short); |
1422 static void c_parser_for_statement (c_parser *, bool, bool *); | 1425 static void c_parser_for_statement (c_parser *, bool, unsigned short, bool *); |
1423 static tree c_parser_asm_statement (c_parser *); | 1426 static tree c_parser_asm_statement (c_parser *); |
1424 static tree c_parser_asm_operands (c_parser *); | 1427 static tree c_parser_asm_operands (c_parser *); |
1425 static tree c_parser_asm_goto_operands (c_parser *); | 1428 static tree c_parser_asm_goto_operands (c_parser *); |
1426 static tree c_parser_asm_clobbers (c_parser *); | 1429 static tree c_parser_asm_clobbers (c_parser *); |
1427 static struct c_expr c_parser_expr_no_commas (c_parser *, struct c_expr *, | 1430 static struct c_expr c_parser_expr_no_commas (c_parser *, struct c_expr *, |
1498 static void c_parser_objc_at_synthesize_declaration (c_parser *); | 1501 static void c_parser_objc_at_synthesize_declaration (c_parser *); |
1499 static void c_parser_objc_at_dynamic_declaration (c_parser *); | 1502 static void c_parser_objc_at_dynamic_declaration (c_parser *); |
1500 static bool c_parser_objc_diagnose_bad_element_prefix | 1503 static bool c_parser_objc_diagnose_bad_element_prefix |
1501 (c_parser *, struct c_declspecs *); | 1504 (c_parser *, struct c_declspecs *); |
1502 | 1505 |
1503 /* Cilk Plus supporting routines. */ | |
1504 static void c_parser_cilk_simd (c_parser *, bool *); | |
1505 static void c_parser_cilk_for (c_parser *, tree, bool *); | |
1506 static bool c_parser_cilk_verify_simd (c_parser *, enum pragma_context); | |
1507 static tree c_parser_array_notation (location_t, c_parser *, tree, tree); | |
1508 static tree c_parser_cilk_clause_vectorlength (c_parser *, tree, bool); | |
1509 static void c_parser_cilk_grainsize (c_parser *, bool *); | |
1510 | |
1511 static void c_parser_parse_rtl_body (c_parser *parser, char *start_with_pass); | 1506 static void c_parser_parse_rtl_body (c_parser *parser, char *start_with_pass); |
1512 | 1507 |
1513 /* Parse a translation unit (C90 6.7, C99 6.9, C11 6.9). | 1508 /* Parse a translation unit (C90 6.7, C99 6.9, C11 6.9). |
1514 | 1509 |
1515 translation-unit: | 1510 translation-unit: |
1665 } | 1660 } |
1666 } | 1661 } |
1667 | 1662 |
1668 static void c_finish_omp_declare_simd (c_parser *, tree, tree, vec<c_token>); | 1663 static void c_finish_omp_declare_simd (c_parser *, tree, tree, vec<c_token>); |
1669 static void c_finish_oacc_routine (struct oacc_routine_data *, tree, bool); | 1664 static void c_finish_oacc_routine (struct oacc_routine_data *, tree, bool); |
1665 | |
1666 /* Build and add a DEBUG_BEGIN_STMT statement with location LOC. */ | |
1667 | |
1668 static void | |
1669 add_debug_begin_stmt (location_t loc) | |
1670 { | |
1671 /* Don't add DEBUG_BEGIN_STMTs outside of functions, see PR84721. */ | |
1672 if (!MAY_HAVE_DEBUG_MARKER_STMTS || !building_stmt_list_p ()) | |
1673 return; | |
1674 | |
1675 tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node); | |
1676 SET_EXPR_LOCATION (stmt, loc); | |
1677 add_stmt (stmt); | |
1678 } | |
1670 | 1679 |
1671 /* Parse a declaration or function definition (C90 6.5, 6.7.1, C99 | 1680 /* Parse a declaration or function definition (C90 6.5, 6.7.1, C99 |
1672 6.7, 6.9.1, C11 6.7, 6.9.1). If FNDEF_OK is true, a function definition | 1681 6.7, 6.9.1, C11 6.7, 6.9.1). If FNDEF_OK is true, a function definition |
1673 is accepted; otherwise (old-style parameter declarations) only other | 1682 is accepted; otherwise (old-style parameter declarations) only other |
1674 declarations are accepted. If STATIC_ASSERT_OK is true, a static | 1683 declarations are accepted. If STATIC_ASSERT_OK is true, a static |
1766 tree prefix_attrs; | 1775 tree prefix_attrs; |
1767 tree all_prefix_attrs; | 1776 tree all_prefix_attrs; |
1768 bool diagnosed_no_specs = false; | 1777 bool diagnosed_no_specs = false; |
1769 location_t here = c_parser_peek_token (parser)->location; | 1778 location_t here = c_parser_peek_token (parser)->location; |
1770 | 1779 |
1780 add_debug_begin_stmt (c_parser_peek_token (parser)->location); | |
1781 | |
1771 if (static_assert_ok | 1782 if (static_assert_ok |
1772 && c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT)) | 1783 && c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT)) |
1773 { | 1784 { |
1774 c_parser_static_assert_declaration (parser); | 1785 c_parser_static_assert_declaration (parser); |
1775 return; | 1786 return; |
1792 gcc_rich_location richloc (here); | 1803 gcc_rich_location richloc (here); |
1793 if (tag_exists_p (RECORD_TYPE, name)) | 1804 if (tag_exists_p (RECORD_TYPE, name)) |
1794 { | 1805 { |
1795 /* This is not C++ with its implicit typedef. */ | 1806 /* This is not C++ with its implicit typedef. */ |
1796 richloc.add_fixit_insert_before ("struct "); | 1807 richloc.add_fixit_insert_before ("struct "); |
1797 error_at_rich_loc (&richloc, | 1808 error_at (&richloc, |
1798 "unknown type name %qE;" | 1809 "unknown type name %qE;" |
1799 " use %<struct%> keyword to refer to the type", | 1810 " use %<struct%> keyword to refer to the type", |
1800 name); | 1811 name); |
1801 } | 1812 } |
1802 else if (tag_exists_p (UNION_TYPE, name)) | 1813 else if (tag_exists_p (UNION_TYPE, name)) |
1803 { | 1814 { |
1804 richloc.add_fixit_insert_before ("union "); | 1815 richloc.add_fixit_insert_before ("union "); |
1805 error_at_rich_loc (&richloc, | 1816 error_at (&richloc, |
1806 "unknown type name %qE;" | 1817 "unknown type name %qE;" |
1807 " use %<union%> keyword to refer to the type", | 1818 " use %<union%> keyword to refer to the type", |
1808 name); | 1819 name); |
1809 } | 1820 } |
1810 else if (tag_exists_p (ENUMERAL_TYPE, name)) | 1821 else if (tag_exists_p (ENUMERAL_TYPE, name)) |
1811 { | 1822 { |
1812 richloc.add_fixit_insert_before ("enum "); | 1823 richloc.add_fixit_insert_before ("enum "); |
1813 error_at_rich_loc (&richloc, | 1824 error_at (&richloc, |
1814 "unknown type name %qE;" | 1825 "unknown type name %qE;" |
1815 " use %<enum%> keyword to refer to the type", | 1826 " use %<enum%> keyword to refer to the type", |
1816 name); | 1827 name); |
1817 } | 1828 } |
1818 else | 1829 else |
1819 { | 1830 { |
1820 const char *hint = lookup_name_fuzzy (name, FUZZY_LOOKUP_TYPENAME); | 1831 auto_diagnostic_group d; |
1832 name_hint hint = lookup_name_fuzzy (name, FUZZY_LOOKUP_TYPENAME, | |
1833 here); | |
1821 if (hint) | 1834 if (hint) |
1822 { | 1835 { |
1823 richloc.add_fixit_replace (hint); | 1836 richloc.add_fixit_replace (hint.suggestion ()); |
1824 error_at_rich_loc (&richloc, | 1837 error_at (&richloc, |
1825 "unknown type name %qE; did you mean %qs?", | 1838 "unknown type name %qE; did you mean %qs?", |
1826 name, hint); | 1839 name, hint.suggestion ()); |
1827 } | 1840 } |
1828 else | 1841 else |
1829 error_at (here, "unknown type name %qE", name); | 1842 error_at (here, "unknown type name %qE", name); |
1830 } | 1843 } |
1831 | 1844 |
1990 declarator = c_parser_declarator (parser, | 2003 declarator = c_parser_declarator (parser, |
1991 specs->typespec_kind != ctsk_none, | 2004 specs->typespec_kind != ctsk_none, |
1992 C_DTR_NORMAL, &dummy); | 2005 C_DTR_NORMAL, &dummy); |
1993 if (declarator == NULL) | 2006 if (declarator == NULL) |
1994 { | 2007 { |
1995 if (omp_declare_simd_clauses.exists () | 2008 if (omp_declare_simd_clauses.exists ()) |
1996 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
1997 c_finish_omp_declare_simd (parser, NULL_TREE, NULL_TREE, | 2009 c_finish_omp_declare_simd (parser, NULL_TREE, NULL_TREE, |
1998 omp_declare_simd_clauses); | 2010 omp_declare_simd_clauses); |
1999 if (oacc_routine_data) | 2011 if (oacc_routine_data) |
2000 c_finish_oacc_routine (oacc_routine_data, NULL_TREE, false); | 2012 c_finish_oacc_routine (oacc_routine_data, NULL_TREE, false); |
2001 c_parser_skip_to_end_of_block_or_statement (parser); | 2013 c_parser_skip_to_end_of_block_or_statement (parser); |
2095 } | 2107 } |
2096 d = start_decl (declarator, specs, true, | 2108 d = start_decl (declarator, specs, true, |
2097 chainon (postfix_attrs, all_prefix_attrs)); | 2109 chainon (postfix_attrs, all_prefix_attrs)); |
2098 if (!d) | 2110 if (!d) |
2099 d = error_mark_node; | 2111 d = error_mark_node; |
2100 if (omp_declare_simd_clauses.exists () | 2112 if (omp_declare_simd_clauses.exists ()) |
2101 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
2102 c_finish_omp_declare_simd (parser, d, NULL_TREE, | 2113 c_finish_omp_declare_simd (parser, d, NULL_TREE, |
2103 omp_declare_simd_clauses); | 2114 omp_declare_simd_clauses); |
2104 } | 2115 } |
2105 else | 2116 else |
2106 { | 2117 { |
2108 its initializer is parsed. */ | 2119 its initializer is parsed. */ |
2109 d = start_decl (declarator, specs, true, | 2120 d = start_decl (declarator, specs, true, |
2110 chainon (postfix_attrs, all_prefix_attrs)); | 2121 chainon (postfix_attrs, all_prefix_attrs)); |
2111 if (!d) | 2122 if (!d) |
2112 d = error_mark_node; | 2123 d = error_mark_node; |
2113 if (omp_declare_simd_clauses.exists () | 2124 if (omp_declare_simd_clauses.exists ()) |
2114 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
2115 c_finish_omp_declare_simd (parser, d, NULL_TREE, | 2125 c_finish_omp_declare_simd (parser, d, NULL_TREE, |
2116 omp_declare_simd_clauses); | 2126 omp_declare_simd_clauses); |
2117 init_loc = c_parser_peek_token (parser)->location; | 2127 init_loc = c_parser_peek_token (parser)->location; |
2118 rich_location richloc (line_table, init_loc); | 2128 rich_location richloc (line_table, init_loc); |
2119 start_init (d, asm_name, global_bindings_p (), &richloc); | 2129 start_init (d, asm_name, global_bindings_p (), &richloc); |
2150 all_prefix_attrs)); | 2160 all_prefix_attrs)); |
2151 if (d && TREE_CODE (d) == FUNCTION_DECL) | 2161 if (d && TREE_CODE (d) == FUNCTION_DECL) |
2152 if (declarator->kind == cdk_function) | 2162 if (declarator->kind == cdk_function) |
2153 if (DECL_ARGUMENTS (d) == NULL_TREE) | 2163 if (DECL_ARGUMENTS (d) == NULL_TREE) |
2154 DECL_ARGUMENTS (d) = declarator->u.arg_info->parms; | 2164 DECL_ARGUMENTS (d) = declarator->u.arg_info->parms; |
2155 if (omp_declare_simd_clauses.exists () | 2165 if (omp_declare_simd_clauses.exists ()) |
2156 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
2157 { | 2166 { |
2158 tree parms = NULL_TREE; | 2167 tree parms = NULL_TREE; |
2159 if (d && TREE_CODE (d) == FUNCTION_DECL) | 2168 if (d && TREE_CODE (d) == FUNCTION_DECL) |
2160 { | 2169 { |
2161 struct c_declarator *ce = declarator; | 2170 struct c_declarator *ce = declarator; |
2307 while (c_parser_next_token_is_not (parser, CPP_EOF) | 2316 while (c_parser_next_token_is_not (parser, CPP_EOF) |
2308 && c_parser_next_token_is_not (parser, CPP_OPEN_BRACE)) | 2317 && c_parser_next_token_is_not (parser, CPP_OPEN_BRACE)) |
2309 c_parser_declaration_or_fndef (parser, false, false, false, | 2318 c_parser_declaration_or_fndef (parser, false, false, false, |
2310 true, false, NULL, vNULL); | 2319 true, false, NULL, vNULL); |
2311 store_parm_decls (); | 2320 store_parm_decls (); |
2312 if (omp_declare_simd_clauses.exists () | 2321 if (omp_declare_simd_clauses.exists ()) |
2313 || !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
2314 c_finish_omp_declare_simd (parser, current_function_decl, NULL_TREE, | 2322 c_finish_omp_declare_simd (parser, current_function_decl, NULL_TREE, |
2315 omp_declare_simd_clauses); | 2323 omp_declare_simd_clauses); |
2316 if (oacc_routine_data) | 2324 if (oacc_routine_data) |
2317 c_finish_oacc_routine (oacc_routine_data, current_function_decl, true); | 2325 c_finish_oacc_routine (oacc_routine_data, current_function_decl, true); |
2318 DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus | 2326 DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus |
2343 | 2351 |
2344 finish_function (); | 2352 finish_function (); |
2345 return; | 2353 return; |
2346 } | 2354 } |
2347 else | 2355 else |
2348 { | 2356 fnbody = c_parser_compound_statement (parser); |
2349 fnbody = c_parser_compound_statement (parser); | |
2350 if (flag_cilkplus && contains_array_notation_expr (fnbody)) | |
2351 fnbody = expand_array_notation_exprs (fnbody); | |
2352 } | |
2353 tree fndecl = current_function_decl; | 2357 tree fndecl = current_function_decl; |
2354 if (nested) | 2358 if (nested) |
2355 { | 2359 { |
2356 tree decl = current_function_decl; | 2360 tree decl = current_function_decl; |
2357 /* Mark nested functions as needing static-chain initially. | 2361 /* Mark nested functions as needing static-chain initially. |
2412 /* Parse a static assertion (C11 6.7.10), without the trailing | 2416 /* Parse a static assertion (C11 6.7.10), without the trailing |
2413 semicolon. | 2417 semicolon. |
2414 | 2418 |
2415 static_assert-declaration-no-semi: | 2419 static_assert-declaration-no-semi: |
2416 _Static_assert ( constant-expression , string-literal ) | 2420 _Static_assert ( constant-expression , string-literal ) |
2421 | |
2422 C2X: | |
2423 static_assert-declaration-no-semi: | |
2424 _Static_assert ( constant-expression ) | |
2417 */ | 2425 */ |
2418 | 2426 |
2419 static void | 2427 static void |
2420 c_parser_static_assert_declaration_no_semi (c_parser *parser) | 2428 c_parser_static_assert_declaration_no_semi (c_parser *parser) |
2421 { | 2429 { |
2422 location_t assert_loc, value_loc; | 2430 location_t assert_loc, value_loc; |
2423 tree value; | 2431 tree value; |
2424 tree string; | 2432 tree string = NULL_TREE; |
2425 | 2433 |
2426 gcc_assert (c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT)); | 2434 gcc_assert (c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT)); |
2427 assert_loc = c_parser_peek_token (parser)->location; | 2435 assert_loc = c_parser_peek_token (parser)->location; |
2428 if (flag_isoc99) | 2436 if (flag_isoc99) |
2429 pedwarn_c99 (assert_loc, OPT_Wpedantic, | 2437 pedwarn_c99 (assert_loc, OPT_Wpedantic, |
2437 return; | 2445 return; |
2438 location_t value_tok_loc = c_parser_peek_token (parser)->location; | 2446 location_t value_tok_loc = c_parser_peek_token (parser)->location; |
2439 value = c_parser_expr_no_commas (parser, NULL).value; | 2447 value = c_parser_expr_no_commas (parser, NULL).value; |
2440 value_loc = EXPR_LOC_OR_LOC (value, value_tok_loc); | 2448 value_loc = EXPR_LOC_OR_LOC (value, value_tok_loc); |
2441 parser->lex_untranslated_string = true; | 2449 parser->lex_untranslated_string = true; |
2442 if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>")) | 2450 if (c_parser_next_token_is (parser, CPP_COMMA)) |
2443 { | 2451 { |
2444 parser->lex_untranslated_string = false; | |
2445 return; | |
2446 } | |
2447 switch (c_parser_peek_token (parser)->type) | |
2448 { | |
2449 case CPP_STRING: | |
2450 case CPP_STRING16: | |
2451 case CPP_STRING32: | |
2452 case CPP_WSTRING: | |
2453 case CPP_UTF8STRING: | |
2454 string = c_parser_peek_token (parser)->value; | |
2455 c_parser_consume_token (parser); | 2452 c_parser_consume_token (parser); |
2456 parser->lex_untranslated_string = false; | 2453 switch (c_parser_peek_token (parser)->type) |
2457 break; | 2454 { |
2458 default: | 2455 case CPP_STRING: |
2459 c_parser_error (parser, "expected string literal"); | 2456 case CPP_STRING16: |
2460 parser->lex_untranslated_string = false; | 2457 case CPP_STRING32: |
2461 return; | 2458 case CPP_WSTRING: |
2462 } | 2459 case CPP_UTF8STRING: |
2460 string = c_parser_peek_token (parser)->value; | |
2461 c_parser_consume_token (parser); | |
2462 parser->lex_untranslated_string = false; | |
2463 break; | |
2464 default: | |
2465 c_parser_error (parser, "expected string literal"); | |
2466 parser->lex_untranslated_string = false; | |
2467 return; | |
2468 } | |
2469 } | |
2470 else if (flag_isoc11) | |
2471 /* If pedantic for pre-C11, the use of _Static_assert itself will | |
2472 have been diagnosed, so do not also diagnose the use of this | |
2473 new C2X feature of _Static_assert. */ | |
2474 pedwarn_c11 (assert_loc, OPT_Wpedantic, | |
2475 "ISO C11 does not support omitting the string in " | |
2476 "%<_Static_assert%>"); | |
2463 parens.require_close (parser); | 2477 parens.require_close (parser); |
2464 | 2478 |
2465 if (!INTEGRAL_TYPE_P (TREE_TYPE (value))) | 2479 if (!INTEGRAL_TYPE_P (TREE_TYPE (value))) |
2466 { | 2480 { |
2467 error_at (value_loc, "expression in static assertion is not an integer"); | 2481 error_at (value_loc, "expression in static assertion is not an integer"); |
2481 error_at (value_loc, "expression in static assertion is not constant"); | 2495 error_at (value_loc, "expression in static assertion is not constant"); |
2482 return; | 2496 return; |
2483 } | 2497 } |
2484 constant_expression_warning (value); | 2498 constant_expression_warning (value); |
2485 if (integer_zerop (value)) | 2499 if (integer_zerop (value)) |
2486 error_at (assert_loc, "static assertion failed: %E", string); | 2500 { |
2501 if (string) | |
2502 error_at (assert_loc, "static assertion failed: %E", string); | |
2503 else | |
2504 error_at (assert_loc, "static assertion failed"); | |
2505 } | |
2487 } | 2506 } |
2488 | 2507 |
2489 /* Parse some declaration specifiers (possibly none) (C90 6.5, C99 | 2508 /* Parse some declaration specifiers (possibly none) (C90 6.5, C99 |
2490 6.7, C11 6.7), adding them to SPECS (which may already include some). | 2509 6.7, C11 6.7), adding them to SPECS (which may already include some). |
2491 Storage class specifiers are accepted iff SCSPEC_OK; type | 2510 Storage class specifiers are accepted iff SCSPEC_OK; type |
2620 one. Also, if we already have seen a tagged definition, | 2639 one. Also, if we already have seen a tagged definition, |
2621 a typename would be an error anyway and likely the user | 2640 a typename would be an error anyway and likely the user |
2622 has simply forgotten a semicolon, so we exit. */ | 2641 has simply forgotten a semicolon, so we exit. */ |
2623 if ((!typespec_ok || specs->typespec_kind == ctsk_tagdef) | 2642 if ((!typespec_ok || specs->typespec_kind == ctsk_tagdef) |
2624 && c_parser_next_tokens_start_typename (parser, la) | 2643 && c_parser_next_tokens_start_typename (parser, la) |
2625 && !c_parser_next_token_is_qualifier (parser)) | 2644 && !c_parser_next_token_is_qualifier (parser) |
2645 && !c_parser_next_token_is_keyword (parser, RID_ALIGNAS)) | |
2626 break; | 2646 break; |
2627 | 2647 |
2628 if (c_parser_next_token_is (parser, CPP_NAME)) | 2648 if (c_parser_next_token_is (parser, CPP_NAME)) |
2629 { | 2649 { |
2630 c_token *name_token = c_parser_peek_token (parser); | 2650 c_token *name_token = c_parser_peek_token (parser); |
3196 { | 3216 { |
3197 location_t semicolon_loc | 3217 location_t semicolon_loc |
3198 = c_parser_peek_token (parser)->location; | 3218 = c_parser_peek_token (parser)->location; |
3199 gcc_rich_location richloc (semicolon_loc); | 3219 gcc_rich_location richloc (semicolon_loc); |
3200 richloc.add_fixit_remove (); | 3220 richloc.add_fixit_remove (); |
3201 pedwarn_at_rich_loc | 3221 pedwarn (&richloc, OPT_Wpedantic, |
3202 (&richloc, OPT_Wpedantic, | 3222 "extra semicolon in struct or union specified"); |
3203 "extra semicolon in struct or union specified"); | |
3204 c_parser_consume_token (parser); | 3223 c_parser_consume_token (parser); |
3205 continue; | 3224 continue; |
3206 } | 3225 } |
3207 /* Stop if at the end of the struct or union contents. */ | 3226 /* Stop if at the end of the struct or union contents. */ |
3208 if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE)) | 3227 if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE)) |
3273 static_assert-declaration-no-semi | 3292 static_assert-declaration-no-semi |
3274 | 3293 |
3275 specifier-qualifier-list: | 3294 specifier-qualifier-list: |
3276 type-specifier specifier-qualifier-list[opt] | 3295 type-specifier specifier-qualifier-list[opt] |
3277 type-qualifier specifier-qualifier-list[opt] | 3296 type-qualifier specifier-qualifier-list[opt] |
3297 alignment-specifier specifier-qualifier-list[opt] | |
3278 attributes specifier-qualifier-list[opt] | 3298 attributes specifier-qualifier-list[opt] |
3279 | 3299 |
3280 struct-declarator-list: | 3300 struct-declarator-list: |
3281 struct-declarator | 3301 struct-declarator |
3282 struct-declarator-list , attributes[opt] struct-declarator | 3302 struct-declarator-list , attributes[opt] struct-declarator |
3825 if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) | 3845 if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) |
3826 { | 3846 { |
3827 dimen.value = NULL_TREE; | 3847 dimen.value = NULL_TREE; |
3828 star_seen = false; | 3848 star_seen = false; |
3829 } | 3849 } |
3830 else if (flag_cilkplus | |
3831 && c_parser_next_token_is (parser, CPP_COLON)) | |
3832 { | |
3833 dimen.value = error_mark_node; | |
3834 star_seen = false; | |
3835 error_at (c_parser_peek_token (parser)->location, | |
3836 "array notations cannot be used in declaration"); | |
3837 c_parser_consume_token (parser); | |
3838 } | |
3839 else if (c_parser_next_token_is (parser, CPP_MULT)) | 3850 else if (c_parser_next_token_is (parser, CPP_MULT)) |
3840 { | 3851 { |
3841 if (c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_SQUARE) | 3852 if (c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_SQUARE) |
3842 { | 3853 { |
3843 dimen.value = NULL_TREE; | 3854 dimen.value = NULL_TREE; |
3856 dimen = c_parser_expr_no_commas (parser, NULL); | 3867 dimen = c_parser_expr_no_commas (parser, NULL); |
3857 } | 3868 } |
3858 } | 3869 } |
3859 if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) | 3870 if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) |
3860 c_parser_consume_token (parser); | 3871 c_parser_consume_token (parser); |
3861 else if (flag_cilkplus | |
3862 && c_parser_next_token_is (parser, CPP_COLON)) | |
3863 { | |
3864 error_at (c_parser_peek_token (parser)->location, | |
3865 "array notations cannot be used in declaration"); | |
3866 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
3867 return NULL; | |
3868 } | |
3869 else | 3872 else |
3870 { | 3873 { |
3871 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, | 3874 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, |
3872 "expected %<]%>"); | 3875 "expected %<]%>"); |
3873 return NULL; | 3876 return NULL; |
4095 if (parser->error) | 4098 if (parser->error) |
4096 return NULL; | 4099 return NULL; |
4097 c_parser_set_source_position_from_token (token); | 4100 c_parser_set_source_position_from_token (token); |
4098 if (c_parser_next_tokens_start_typename (parser, cla_prefer_type)) | 4101 if (c_parser_next_tokens_start_typename (parser, cla_prefer_type)) |
4099 { | 4102 { |
4100 const char *hint = lookup_name_fuzzy (token->value, | 4103 auto_diagnostic_group d; |
4101 FUZZY_LOOKUP_TYPENAME); | 4104 name_hint hint = lookup_name_fuzzy (token->value, |
4105 FUZZY_LOOKUP_TYPENAME, | |
4106 token->location); | |
4102 if (hint) | 4107 if (hint) |
4103 { | 4108 { |
4104 gcc_rich_location richloc (token->location); | 4109 gcc_rich_location richloc (token->location); |
4105 richloc.add_fixit_replace (hint); | 4110 richloc.add_fixit_replace (hint.suggestion ()); |
4106 error_at_rich_loc (&richloc, | 4111 error_at (&richloc, |
4107 "unknown type name %qE; did you mean %qs?", | 4112 "unknown type name %qE; did you mean %qs?", |
4108 token->value, hint); | 4113 token->value, hint.suggestion ()); |
4109 } | 4114 } |
4110 else | 4115 else |
4111 error_at (token->location, "unknown type name %qE", token->value); | 4116 error_at (token->location, "unknown type name %qE", token->value); |
4112 parser->error = true; | 4117 parser->error = true; |
4113 } | 4118 } |
4308 attr_name = c_parser_peek_token (parser)->value; | 4313 attr_name = c_parser_peek_token (parser)->value; |
4309 | 4314 |
4310 return attr_name; | 4315 return attr_name; |
4311 } | 4316 } |
4312 | 4317 |
4313 #define CILK_SIMD_FN_CLAUSE_MASK \ | |
4314 ((OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_VECTORLENGTH) \ | |
4315 | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_LINEAR) \ | |
4316 | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_UNIFORM) \ | |
4317 | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_MASK) \ | |
4318 | (OMP_CLAUSE_MASK_1 << PRAGMA_CILK_CLAUSE_NOMASK)) | |
4319 | |
4320 /* Parses the vector attribute of SIMD enabled functions in Cilk Plus. | |
4321 VEC_TOKEN is the "vector" token that is replaced with "simd" and | |
4322 pushed into the token list. | |
4323 Syntax: | |
4324 vector | |
4325 vector (<vector attributes>). */ | |
4326 | |
4327 static void | |
4328 c_parser_cilk_simd_fn_vector_attrs (c_parser *parser, c_token vec_token) | |
4329 { | |
4330 gcc_assert (is_cilkplus_vector_p (vec_token.value)); | |
4331 | |
4332 int paren_scope = 0; | |
4333 vec_safe_push (parser->cilk_simd_fn_tokens, vec_token); | |
4334 /* Consume the "vector" token. */ | |
4335 c_parser_consume_token (parser); | |
4336 | |
4337 if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)) | |
4338 { | |
4339 c_parser_consume_token (parser); | |
4340 paren_scope++; | |
4341 } | |
4342 while (paren_scope > 0) | |
4343 { | |
4344 c_token *token = c_parser_peek_token (parser); | |
4345 if (token->type == CPP_OPEN_PAREN) | |
4346 paren_scope++; | |
4347 else if (token->type == CPP_CLOSE_PAREN) | |
4348 paren_scope--; | |
4349 /* Do not push the last ')' since we are not pushing the '('. */ | |
4350 if (!(token->type == CPP_CLOSE_PAREN && paren_scope == 0)) | |
4351 vec_safe_push (parser->cilk_simd_fn_tokens, *token); | |
4352 c_parser_consume_token (parser); | |
4353 } | |
4354 | |
4355 /* Since we are converting an attribute to a pragma, we need to end the | |
4356 attribute with PRAGMA_EOL. */ | |
4357 c_token eol_token; | |
4358 memset (&eol_token, 0, sizeof (eol_token)); | |
4359 eol_token.type = CPP_PRAGMA_EOL; | |
4360 vec_safe_push (parser->cilk_simd_fn_tokens, eol_token); | |
4361 } | |
4362 | |
4363 /* Add 2 CPP_EOF at the end of PARSER->ELEM_FN_TOKENS vector. */ | |
4364 | |
4365 static void | |
4366 c_finish_cilk_simd_fn_tokens (c_parser *parser) | |
4367 { | |
4368 c_token last_token = parser->cilk_simd_fn_tokens->last (); | |
4369 | |
4370 /* c_parser_attributes is called in several places, so if these EOF | |
4371 tokens are already inserted, then don't do them again. */ | |
4372 if (last_token.type == CPP_EOF) | |
4373 return; | |
4374 | |
4375 /* Two CPP_EOF token are added as a safety net since the normal C | |
4376 front-end has two token look-ahead. */ | |
4377 c_token eof_token; | |
4378 eof_token.type = CPP_EOF; | |
4379 vec_safe_push (parser->cilk_simd_fn_tokens, eof_token); | |
4380 vec_safe_push (parser->cilk_simd_fn_tokens, eof_token); | |
4381 } | |
4382 | |
4383 /* Parse (possibly empty) attributes. This is a GNU extension. | 4318 /* Parse (possibly empty) attributes. This is a GNU extension. |
4384 | 4319 |
4385 attributes: | 4320 attributes: |
4386 empty | 4321 empty |
4387 attributes attribute | 4322 attributes attribute |
4445 | 4380 |
4446 attr_name = c_parser_attribute_any_word (parser); | 4381 attr_name = c_parser_attribute_any_word (parser); |
4447 if (attr_name == NULL) | 4382 if (attr_name == NULL) |
4448 break; | 4383 break; |
4449 attr_name = canonicalize_attr_name (attr_name); | 4384 attr_name = canonicalize_attr_name (attr_name); |
4450 if (is_cilkplus_vector_p (attr_name)) | |
4451 { | |
4452 c_token *v_token = c_parser_peek_token (parser); | |
4453 v_token->value = canonicalize_attr_name (v_token->value); | |
4454 c_parser_cilk_simd_fn_vector_attrs (parser, *v_token); | |
4455 /* If the next token isn't a comma, we're done. */ | |
4456 if (!c_parser_next_token_is (parser, CPP_COMMA)) | |
4457 break; | |
4458 continue; | |
4459 } | |
4460 c_parser_consume_token (parser); | 4385 c_parser_consume_token (parser); |
4461 if (c_parser_next_token_is_not (parser, CPP_OPEN_PAREN)) | 4386 if (c_parser_next_token_is_not (parser, CPP_OPEN_PAREN)) |
4462 { | 4387 { |
4463 attr = build_tree_list (attr_name, NULL_TREE); | 4388 attr = build_tree_list (attr_name, NULL_TREE); |
4464 /* Add this attribute to the list. */ | 4389 /* Add this attribute to the list. */ |
4551 return attrs; | 4476 return attrs; |
4552 } | 4477 } |
4553 parser->lex_untranslated_string = false; | 4478 parser->lex_untranslated_string = false; |
4554 } | 4479 } |
4555 | 4480 |
4556 if (flag_cilkplus && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
4557 c_finish_cilk_simd_fn_tokens (parser); | |
4558 return attrs; | 4481 return attrs; |
4559 } | 4482 } |
4560 | 4483 |
4561 /* Parse a type name (C90 6.5.5, C99 6.7.6, C11 6.7.7). | 4484 /* Parse a type name (C90 6.5.5, C99 6.7.6, C11 6.7.7). ALIGNAS_OK |
4485 says whether alignment specifiers are OK (only in cases that might | |
4486 be the type name of a compound literal). | |
4562 | 4487 |
4563 type-name: | 4488 type-name: |
4564 specifier-qualifier-list abstract-declarator[opt] | 4489 specifier-qualifier-list abstract-declarator[opt] |
4565 */ | 4490 */ |
4566 | 4491 |
4567 struct c_type_name * | 4492 struct c_type_name * |
4568 c_parser_type_name (c_parser *parser) | 4493 c_parser_type_name (c_parser *parser, bool alignas_ok) |
4569 { | 4494 { |
4570 struct c_declspecs *specs = build_null_declspecs (); | 4495 struct c_declspecs *specs = build_null_declspecs (); |
4571 struct c_declarator *declarator; | 4496 struct c_declarator *declarator; |
4572 struct c_type_name *ret; | 4497 struct c_type_name *ret; |
4573 bool dummy = false; | 4498 bool dummy = false; |
4574 c_parser_declspecs (parser, specs, false, true, true, false, false, | 4499 c_parser_declspecs (parser, specs, false, true, true, alignas_ok, false, |
4575 cla_prefer_type); | 4500 cla_prefer_type); |
4576 if (!specs->declspecs_seen_p) | 4501 if (!specs->declspecs_seen_p) |
4577 { | 4502 { |
4578 c_parser_error (parser, "expected specifier-qualifier-list"); | 4503 c_parser_error (parser, "expected specifier-qualifier-list"); |
4579 return NULL; | 4504 return NULL; |
4708 } | 4633 } |
4709 } | 4634 } |
4710 c_token *next_tok = c_parser_peek_token (parser); | 4635 c_token *next_tok = c_parser_peek_token (parser); |
4711 if (next_tok->type != CPP_CLOSE_BRACE) | 4636 if (next_tok->type != CPP_CLOSE_BRACE) |
4712 { | 4637 { |
4713 ret.value = error_mark_node; | 4638 ret.set_error (); |
4714 ret.original_code = ERROR_MARK; | 4639 ret.original_code = ERROR_MARK; |
4715 ret.original_type = NULL; | 4640 ret.original_type = NULL; |
4716 braces.skip_until_found_close (parser); | 4641 braces.skip_until_found_close (parser); |
4717 pop_init_level (brace_loc, 0, &braced_init_obstack, last_init_list_comma); | 4642 pop_init_level (brace_loc, 0, &braced_init_obstack, last_init_list_comma); |
4718 obstack_free (&braced_init_obstack, NULL); | 4643 obstack_free (&braced_init_obstack, NULL); |
4775 c_parser_consume_token (parser); | 4700 c_parser_consume_token (parser); |
4776 } | 4701 } |
4777 else | 4702 else |
4778 { | 4703 { |
4779 struct c_expr init; | 4704 struct c_expr init; |
4780 init.value = error_mark_node; | 4705 init.set_error (); |
4781 init.original_code = ERROR_MARK; | 4706 init.original_code = ERROR_MARK; |
4782 init.original_type = NULL; | 4707 init.original_type = NULL; |
4783 c_parser_error (parser, "expected identifier"); | 4708 c_parser_error (parser, "expected identifier"); |
4784 c_parser_skip_until_found (parser, CPP_COMMA, NULL); | 4709 c_parser_skip_until_found (parser, CPP_COMMA, NULL); |
4785 process_init_element (input_location, init, false, | 4710 process_init_element (input_location, init, false, |
4911 pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic, | 4836 pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic, |
4912 "obsolete use of designated initializer without %<=%>"); | 4837 "obsolete use of designated initializer without %<=%>"); |
4913 else | 4838 else |
4914 { | 4839 { |
4915 struct c_expr init; | 4840 struct c_expr init; |
4916 init.value = error_mark_node; | 4841 init.set_error (); |
4917 init.original_code = ERROR_MARK; | 4842 init.original_code = ERROR_MARK; |
4918 init.original_type = NULL; | 4843 init.original_type = NULL; |
4919 c_parser_error (parser, "expected %<=%>"); | 4844 c_parser_error (parser, "expected %<=%>"); |
4920 c_parser_skip_until_found (parser, CPP_COMMA, NULL); | 4845 c_parser_skip_until_found (parser, CPP_COMMA, NULL); |
4921 process_init_element (input_location, init, false, | 4846 process_init_element (input_location, init, false, |
5036 return error_mark_node; | 4961 return error_mark_node; |
5037 } | 4962 } |
5038 stmt = c_begin_compound_stmt (true); | 4963 stmt = c_begin_compound_stmt (true); |
5039 c_parser_compound_statement_nostart (parser); | 4964 c_parser_compound_statement_nostart (parser); |
5040 | 4965 |
5041 /* If the compound stmt contains array notations, then we expand them. */ | |
5042 if (flag_cilkplus && contains_array_notation_expr (stmt)) | |
5043 stmt = expand_array_notation_exprs (stmt); | |
5044 return c_end_compound_stmt (brace_loc, stmt, true); | 4966 return c_end_compound_stmt (brace_loc, stmt, true); |
5045 } | 4967 } |
5046 | 4968 |
5047 /* Parse a compound statement except for the opening brace. This is | 4969 /* Parse a compound statement except for the opening brace. This is |
5048 used for parsing both compound statements and statement expressions | 4970 used for parsing both compound statements and statement expressions |
5055 bool last_label = false; | 4977 bool last_label = false; |
5056 bool save_valid_for_pragma = valid_location_for_stdc_pragma_p (); | 4978 bool save_valid_for_pragma = valid_location_for_stdc_pragma_p (); |
5057 location_t label_loc = UNKNOWN_LOCATION; /* Quiet warning. */ | 4979 location_t label_loc = UNKNOWN_LOCATION; /* Quiet warning. */ |
5058 if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE)) | 4980 if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE)) |
5059 { | 4981 { |
4982 add_debug_begin_stmt (c_parser_peek_token (parser)->location); | |
5060 c_parser_consume_token (parser); | 4983 c_parser_consume_token (parser); |
5061 return; | 4984 return; |
5062 } | 4985 } |
5063 mark_valid_location_for_stdc_pragma (true); | 4986 mark_valid_location_for_stdc_pragma (true); |
5064 if (c_parser_next_token_is_keyword (parser, RID_LABEL)) | 4987 if (c_parser_next_token_is_keyword (parser, RID_LABEL)) |
5103 return; | 5026 return; |
5104 } | 5027 } |
5105 while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE)) | 5028 while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE)) |
5106 { | 5029 { |
5107 location_t loc = c_parser_peek_token (parser)->location; | 5030 location_t loc = c_parser_peek_token (parser)->location; |
5031 loc = expansion_point_location_if_in_system_header (loc); | |
5108 if (c_parser_next_token_is_keyword (parser, RID_CASE) | 5032 if (c_parser_next_token_is_keyword (parser, RID_CASE) |
5109 || c_parser_next_token_is_keyword (parser, RID_DEFAULT) | 5033 || c_parser_next_token_is_keyword (parser, RID_DEFAULT) |
5110 || (c_parser_next_token_is (parser, CPP_NAME) | 5034 || (c_parser_next_token_is (parser, CPP_NAME) |
5111 && c_parser_peek_2nd_token (parser)->type == CPP_COLON)) | 5035 && c_parser_peek_2nd_token (parser)->type == CPP_COLON)) |
5112 { | 5036 { |
5548 tree stmt = NULL_TREE; | 5472 tree stmt = NULL_TREE; |
5549 bool in_if_block = parser->in_if_block; | 5473 bool in_if_block = parser->in_if_block; |
5550 parser->in_if_block = false; | 5474 parser->in_if_block = false; |
5551 if (if_p != NULL) | 5475 if (if_p != NULL) |
5552 *if_p = false; | 5476 *if_p = false; |
5477 | |
5478 if (c_parser_peek_token (parser)->type != CPP_OPEN_BRACE) | |
5479 add_debug_begin_stmt (loc); | |
5480 | |
5553 switch (c_parser_peek_token (parser)->type) | 5481 switch (c_parser_peek_token (parser)->type) |
5554 { | 5482 { |
5555 case CPP_OPEN_BRACE: | 5483 case CPP_OPEN_BRACE: |
5556 add_stmt (c_parser_compound_statement (parser)); | 5484 add_stmt (c_parser_compound_statement (parser)); |
5557 break; | 5485 break; |
5563 break; | 5491 break; |
5564 case RID_SWITCH: | 5492 case RID_SWITCH: |
5565 c_parser_switch_statement (parser, if_p); | 5493 c_parser_switch_statement (parser, if_p); |
5566 break; | 5494 break; |
5567 case RID_WHILE: | 5495 case RID_WHILE: |
5568 c_parser_while_statement (parser, false, if_p); | 5496 c_parser_while_statement (parser, false, 0, if_p); |
5569 break; | 5497 break; |
5570 case RID_DO: | 5498 case RID_DO: |
5571 c_parser_do_statement (parser, false); | 5499 c_parser_do_statement (parser, 0, false); |
5572 break; | 5500 break; |
5573 case RID_FOR: | 5501 case RID_FOR: |
5574 c_parser_for_statement (parser, false, if_p); | 5502 c_parser_for_statement (parser, false, 0, if_p); |
5575 break; | |
5576 case RID_CILK_FOR: | |
5577 if (!flag_cilkplus) | |
5578 { | |
5579 error_at (c_parser_peek_token (parser)->location, | |
5580 "-fcilkplus must be enabled to use %<_Cilk_for%>"); | |
5581 c_parser_skip_to_end_of_block_or_statement (parser); | |
5582 } | |
5583 else | |
5584 c_parser_cilk_for (parser, integer_zero_node, if_p); | |
5585 break; | |
5586 case RID_CILK_SYNC: | |
5587 c_parser_consume_token (parser); | |
5588 c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); | |
5589 if (!flag_cilkplus) | |
5590 error_at (loc, "-fcilkplus must be enabled to use %<_Cilk_sync%>"); | |
5591 else | |
5592 add_stmt (build_cilk_sync ()); | |
5593 break; | 5503 break; |
5594 case RID_GOTO: | 5504 case RID_GOTO: |
5595 c_parser_consume_token (parser); | 5505 c_parser_consume_token (parser); |
5596 #ifndef noCbC | 5506 #ifndef noCbC |
5597 if ( c_parser_next_token_is (parser, CPP_NAME) | 5507 if ( c_parser_next_token_is (parser, CPP_NAME) |
5609 { | 5519 { |
5610 struct c_expr val; | 5520 struct c_expr val; |
5611 | 5521 |
5612 c_parser_consume_token (parser); | 5522 c_parser_consume_token (parser); |
5613 val = c_parser_expression (parser); | 5523 val = c_parser_expression (parser); |
5614 if (check_no_cilk (val.value, | |
5615 "Cilk array notation cannot be used as a computed goto expression", | |
5616 "%<_Cilk_spawn%> statement cannot be used as a computed goto expression", | |
5617 loc)) | |
5618 val.value = error_mark_node; | |
5619 val = convert_lvalue_to_rvalue (loc, val, false, true); | 5524 val = convert_lvalue_to_rvalue (loc, val, false, true); |
5620 stmt = c_finish_goto_ptr (loc, val.value); | 5525 stmt = c_finish_goto_ptr (loc, val.value); |
5621 } | 5526 } |
5622 else | 5527 else |
5623 #ifndef noCbC | 5528 #ifndef noCbC |
5701 } | 5606 } |
5702 else | 5607 else |
5703 { | 5608 { |
5704 struct c_expr expr = c_parser_expression (parser); | 5609 struct c_expr expr = c_parser_expression (parser); |
5705 expr = convert_lvalue_to_rvalue (loc, expr, false, false); | 5610 expr = convert_lvalue_to_rvalue (loc, expr, false, false); |
5706 if (check_no_cilk (expr.value, | 5611 expr.value = c_fully_fold (expr.value, false, NULL); |
5707 "Cilk array notation cannot be used for a throw expression", | 5612 stmt = objc_build_throw_stmt (loc, expr.value); |
5708 "%<_Cilk_spawn%> statement cannot be used for a throw expression")) | |
5709 expr.value = error_mark_node; | |
5710 else | |
5711 { | |
5712 expr.value = c_fully_fold (expr.value, false, NULL); | |
5713 stmt = objc_build_throw_stmt (loc, expr.value); | |
5714 } | |
5715 goto expect_semicolon; | 5613 goto expect_semicolon; |
5716 } | 5614 } |
5717 break; | 5615 break; |
5718 case RID_AT_TRY: | 5616 case RID_AT_TRY: |
5719 gcc_assert (c_dialect_objc ()); | 5617 gcc_assert (c_dialect_objc ()); |
5987 location_t loc; | 5885 location_t loc; |
5988 tree cond; | 5886 tree cond; |
5989 bool nested_if = false; | 5887 bool nested_if = false; |
5990 tree first_body, second_body; | 5888 tree first_body, second_body; |
5991 bool in_if_block; | 5889 bool in_if_block; |
5992 tree if_stmt; | |
5993 | 5890 |
5994 gcc_assert (c_parser_next_token_is_keyword (parser, RID_IF)); | 5891 gcc_assert (c_parser_next_token_is_keyword (parser, RID_IF)); |
5995 token_indent_info if_tinfo | 5892 token_indent_info if_tinfo |
5996 = get_token_indent_info (c_parser_peek_token (parser)); | 5893 = get_token_indent_info (c_parser_peek_token (parser)); |
5997 c_parser_consume_token (parser); | 5894 c_parser_consume_token (parser); |
5998 block = c_begin_compound_stmt (flag_isoc99); | 5895 block = c_begin_compound_stmt (flag_isoc99); |
5999 loc = c_parser_peek_token (parser)->location; | 5896 loc = c_parser_peek_token (parser)->location; |
6000 cond = c_parser_paren_condition (parser); | 5897 cond = c_parser_paren_condition (parser); |
6001 if (flag_cilkplus && contains_cilk_spawn_stmt (cond)) | |
6002 { | |
6003 error_at (loc, "if statement cannot contain %<Cilk_spawn%>"); | |
6004 cond = error_mark_node; | |
6005 } | |
6006 in_if_block = parser->in_if_block; | 5898 in_if_block = parser->in_if_block; |
6007 parser->in_if_block = true; | 5899 parser->in_if_block = true; |
6008 first_body = c_parser_if_body (parser, &nested_if, if_tinfo); | 5900 first_body = c_parser_if_body (parser, &nested_if, if_tinfo); |
6009 parser->in_if_block = in_if_block; | 5901 parser->in_if_block = in_if_block; |
6010 | 5902 |
6059 delete chain; | 5951 delete chain; |
6060 chain = NULL; | 5952 chain = NULL; |
6061 } | 5953 } |
6062 } | 5954 } |
6063 c_finish_if_stmt (loc, cond, first_body, second_body); | 5955 c_finish_if_stmt (loc, cond, first_body, second_body); |
6064 if_stmt = c_end_compound_stmt (loc, block, flag_isoc99); | 5956 add_stmt (c_end_compound_stmt (loc, block, flag_isoc99)); |
6065 | 5957 |
6066 /* If the if statement contains array notations, then we expand them. */ | |
6067 if (flag_cilkplus && contains_array_notation_expr (if_stmt)) | |
6068 if_stmt = fix_conditional_array_notations (if_stmt); | |
6069 add_stmt (if_stmt); | |
6070 c_parser_maybe_reclassify_token (parser); | 5958 c_parser_maybe_reclassify_token (parser); |
6071 } | 5959 } |
6072 | 5960 |
6073 /* Parse a switch statement (C90 6.6.4, C99 6.8.4, C11 6.8.4). | 5961 /* Parse a switch statement (C90 6.6.4, C99 6.8.4, C11 6.8.4). |
6074 | 5962 |
6096 explicit_cast_p = true; | 5984 explicit_cast_p = true; |
6097 ce = c_parser_expression (parser); | 5985 ce = c_parser_expression (parser); |
6098 ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, false); | 5986 ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, false); |
6099 expr = ce.value; | 5987 expr = ce.value; |
6100 /* ??? expr has no valid location? */ | 5988 /* ??? expr has no valid location? */ |
6101 if (check_no_cilk (expr, | |
6102 "Cilk array notation cannot be used as a condition for switch statement", | |
6103 "%<_Cilk_spawn%> statement cannot be used as a condition for switch statement", | |
6104 switch_cond_loc)) | |
6105 expr = error_mark_node; | |
6106 parens.skip_until_found_close (parser); | 5989 parens.skip_until_found_close (parser); |
6107 } | 5990 } |
6108 else | 5991 else |
6109 { | 5992 { |
6110 switch_cond_loc = UNKNOWN_LOCATION; | 5993 switch_cond_loc = UNKNOWN_LOCATION; |
6119 body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels); | 6002 body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels); |
6120 location_t next_loc = c_parser_peek_token (parser)->location; | 6003 location_t next_loc = c_parser_peek_token (parser)->location; |
6121 if (!open_brace_p && c_parser_peek_token (parser)->type != CPP_SEMICOLON) | 6004 if (!open_brace_p && c_parser_peek_token (parser)->type != CPP_SEMICOLON) |
6122 warn_for_multistatement_macros (loc_after_labels, next_loc, switch_loc, | 6005 warn_for_multistatement_macros (loc_after_labels, next_loc, switch_loc, |
6123 RID_SWITCH); | 6006 RID_SWITCH); |
6124 c_finish_case (body, ce.original_type); | |
6125 if (c_break_label) | 6007 if (c_break_label) |
6126 { | 6008 { |
6127 location_t here = c_parser_peek_token (parser)->location; | 6009 location_t here = c_parser_peek_token (parser)->location; |
6128 tree t = build1 (LABEL_EXPR, void_type_node, c_break_label); | 6010 tree t = build1 (LABEL_EXPR, void_type_node, c_break_label); |
6129 SET_EXPR_LOCATION (t, here); | 6011 SET_EXPR_LOCATION (t, here); |
6130 add_stmt (t); | 6012 SWITCH_BREAK_LABEL_P (c_break_label) = 1; |
6131 } | 6013 append_to_statement_list_force (t, &body); |
6014 } | |
6015 c_finish_case (body, ce.original_type); | |
6132 c_break_label = save_break; | 6016 c_break_label = save_break; |
6133 add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99)); | 6017 add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99)); |
6134 c_parser_maybe_reclassify_token (parser); | 6018 c_parser_maybe_reclassify_token (parser); |
6135 } | 6019 } |
6136 | 6020 |
6142 IF_P is used to track whether there's a (possibly labeled) if statement | 6026 IF_P is used to track whether there's a (possibly labeled) if statement |
6143 which is not enclosed in braces and has an else clause. This is used to | 6027 which is not enclosed in braces and has an else clause. This is used to |
6144 implement -Wparentheses. */ | 6028 implement -Wparentheses. */ |
6145 | 6029 |
6146 static void | 6030 static void |
6147 c_parser_while_statement (c_parser *parser, bool ivdep, bool *if_p) | 6031 c_parser_while_statement (c_parser *parser, bool ivdep, unsigned short unroll, |
6032 bool *if_p) | |
6148 { | 6033 { |
6149 tree block, cond, body, save_break, save_cont; | 6034 tree block, cond, body, save_break, save_cont; |
6150 location_t loc; | 6035 location_t loc; |
6151 gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE)); | 6036 gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE)); |
6152 token_indent_info while_tinfo | 6037 token_indent_info while_tinfo |
6153 = get_token_indent_info (c_parser_peek_token (parser)); | 6038 = get_token_indent_info (c_parser_peek_token (parser)); |
6154 c_parser_consume_token (parser); | 6039 c_parser_consume_token (parser); |
6155 block = c_begin_compound_stmt (flag_isoc99); | 6040 block = c_begin_compound_stmt (flag_isoc99); |
6156 loc = c_parser_peek_token (parser)->location; | 6041 loc = c_parser_peek_token (parser)->location; |
6157 cond = c_parser_paren_condition (parser); | 6042 cond = c_parser_paren_condition (parser); |
6158 if (check_no_cilk (cond, | |
6159 "Cilk array notation cannot be used as a condition for while statement", | |
6160 "%<_Cilk_spawn%> statement cannot be used as a condition for while statement")) | |
6161 cond = error_mark_node; | |
6162 if (ivdep && cond != error_mark_node) | 6043 if (ivdep && cond != error_mark_node) |
6163 cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | 6044 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, |
6164 build_int_cst (integer_type_node, | 6045 build_int_cst (integer_type_node, |
6165 annot_expr_ivdep_kind)); | 6046 annot_expr_ivdep_kind), |
6047 integer_zero_node); | |
6048 if (unroll && cond != error_mark_node) | |
6049 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | |
6050 build_int_cst (integer_type_node, | |
6051 annot_expr_unroll_kind), | |
6052 build_int_cst (integer_type_node, unroll)); | |
6166 save_break = c_break_label; | 6053 save_break = c_break_label; |
6167 c_break_label = NULL_TREE; | 6054 c_break_label = NULL_TREE; |
6168 save_cont = c_cont_label; | 6055 save_cont = c_cont_label; |
6169 c_cont_label = NULL_TREE; | 6056 c_cont_label = NULL_TREE; |
6170 | 6057 |
6195 do-statement: | 6082 do-statement: |
6196 do statement while ( expression ) ; | 6083 do statement while ( expression ) ; |
6197 */ | 6084 */ |
6198 | 6085 |
6199 static void | 6086 static void |
6200 c_parser_do_statement (c_parser *parser, bool ivdep) | 6087 c_parser_do_statement (c_parser *parser, bool ivdep, unsigned short unroll) |
6201 { | 6088 { |
6202 tree block, cond, body, save_break, save_cont, new_break, new_cont; | 6089 tree block, cond, body, save_break, save_cont, new_break, new_cont; |
6203 location_t loc; | 6090 location_t loc; |
6204 gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO)); | 6091 gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO)); |
6205 c_parser_consume_token (parser); | 6092 c_parser_consume_token (parser); |
6218 new_break = c_break_label; | 6105 new_break = c_break_label; |
6219 c_break_label = save_break; | 6106 c_break_label = save_break; |
6220 new_cont = c_cont_label; | 6107 new_cont = c_cont_label; |
6221 c_cont_label = save_cont; | 6108 c_cont_label = save_cont; |
6222 cond = c_parser_paren_condition (parser); | 6109 cond = c_parser_paren_condition (parser); |
6223 if (check_no_cilk (cond, | |
6224 "Cilk array notation cannot be used as a condition for a do-while statement", | |
6225 "%<_Cilk_spawn%> statement cannot be used as a condition for a do-while statement")) | |
6226 cond = error_mark_node; | |
6227 if (ivdep && cond != error_mark_node) | 6110 if (ivdep && cond != error_mark_node) |
6228 cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | 6111 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, |
6229 build_int_cst (integer_type_node, | 6112 build_int_cst (integer_type_node, |
6230 annot_expr_ivdep_kind)); | 6113 annot_expr_ivdep_kind), |
6114 integer_zero_node); | |
6115 if (unroll && cond != error_mark_node) | |
6116 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | |
6117 build_int_cst (integer_type_node, | |
6118 annot_expr_unroll_kind), | |
6119 build_int_cst (integer_type_node, unroll)); | |
6231 if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) | 6120 if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) |
6232 c_parser_skip_to_end_of_block_or_statement (parser); | 6121 c_parser_skip_to_end_of_block_or_statement (parser); |
6233 c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false); | 6122 c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false); |
6234 add_stmt (c_end_compound_stmt (loc, block, flag_isoc99)); | 6123 add_stmt (c_end_compound_stmt (loc, block, flag_isoc99)); |
6235 } | 6124 } |
6292 IF_P is used to track whether there's a (possibly labeled) if statement | 6181 IF_P is used to track whether there's a (possibly labeled) if statement |
6293 which is not enclosed in braces and has an else clause. This is used to | 6182 which is not enclosed in braces and has an else clause. This is used to |
6294 implement -Wparentheses. */ | 6183 implement -Wparentheses. */ |
6295 | 6184 |
6296 static void | 6185 static void |
6297 c_parser_for_statement (c_parser *parser, bool ivdep, bool *if_p) | 6186 c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, |
6187 bool *if_p) | |
6298 { | 6188 { |
6299 tree block, cond, incr, save_break, save_cont, body; | 6189 tree block, cond, incr, save_break, save_cont, body; |
6300 /* The following are only used when parsing an ObjC foreach statement. */ | 6190 /* The following are only used when parsing an ObjC foreach statement. */ |
6301 tree object_expression; | 6191 tree object_expression; |
6302 /* Silence the bogus uninitialized warning. */ | 6192 /* Silence the bogus uninitialized warning. */ |
6379 init_expr: | 6269 init_expr: |
6380 { | 6270 { |
6381 struct c_expr ce; | 6271 struct c_expr ce; |
6382 tree init_expression; | 6272 tree init_expression; |
6383 ce = c_parser_expression (parser); | 6273 ce = c_parser_expression (parser); |
6384 /* In theory we could forbid _Cilk_spawn here, as the spec says "only in top | |
6385 level statement", but it works just fine, so allow it. */ | |
6386 init_expression = ce.value; | 6274 init_expression = ce.value; |
6387 parser->objc_could_be_foreach_context = false; | 6275 parser->objc_could_be_foreach_context = false; |
6388 if (c_parser_next_token_is_keyword (parser, RID_IN)) | 6276 if (c_parser_next_token_is_keyword (parser, RID_IN)) |
6389 { | 6277 { |
6390 c_parser_consume_token (parser); | 6278 c_parser_consume_token (parser); |
6413 { | 6301 { |
6414 c_parser_error (parser, "missing loop condition in loop with " | 6302 c_parser_error (parser, "missing loop condition in loop with " |
6415 "%<GCC ivdep%> pragma"); | 6303 "%<GCC ivdep%> pragma"); |
6416 cond = error_mark_node; | 6304 cond = error_mark_node; |
6417 } | 6305 } |
6306 else if (unroll) | |
6307 { | |
6308 c_parser_error (parser, "missing loop condition in loop with " | |
6309 "%<GCC unroll%> pragma"); | |
6310 cond = error_mark_node; | |
6311 } | |
6418 else | 6312 else |
6419 { | 6313 { |
6420 c_parser_consume_token (parser); | 6314 c_parser_consume_token (parser); |
6421 cond = NULL_TREE; | 6315 cond = NULL_TREE; |
6422 } | 6316 } |
6423 } | 6317 } |
6424 else | 6318 else |
6425 { | 6319 { |
6426 cond = c_parser_condition (parser); | 6320 cond = c_parser_condition (parser); |
6427 if (check_no_cilk (cond, | |
6428 "Cilk array notation cannot be used in a condition for a for-loop", | |
6429 "%<_Cilk_spawn%> statement cannot be used in a condition for a for-loop")) | |
6430 cond = error_mark_node; | |
6431 c_parser_skip_until_found (parser, CPP_SEMICOLON, | 6321 c_parser_skip_until_found (parser, CPP_SEMICOLON, |
6432 "expected %<;%>"); | 6322 "expected %<;%>"); |
6433 } | 6323 } |
6434 if (ivdep && cond != error_mark_node) | 6324 if (ivdep && cond != error_mark_node) |
6435 cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | 6325 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, |
6436 build_int_cst (integer_type_node, | 6326 build_int_cst (integer_type_node, |
6437 annot_expr_ivdep_kind)); | 6327 annot_expr_ivdep_kind), |
6328 integer_zero_node); | |
6329 if (unroll && cond != error_mark_node) | |
6330 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | |
6331 build_int_cst (integer_type_node, | |
6332 annot_expr_unroll_kind), | |
6333 build_int_cst (integer_type_node, unroll)); | |
6438 } | 6334 } |
6439 /* Parse the increment expression (the third expression in a | 6335 /* Parse the increment expression (the third expression in a |
6440 for-statement). In the case of a foreach-statement, this is | 6336 for-statement). In the case of a foreach-statement, this is |
6441 the expression that follows the 'in'. */ | 6337 the expression that follows the 'in'. */ |
6442 if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) | 6338 if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) |
6927 | 6823 |
6928 colon_loc = c_parser_peek_token (parser)->location; | 6824 colon_loc = c_parser_peek_token (parser)->location; |
6929 if (!c_parser_require (parser, CPP_COLON, "expected %<:%>")) | 6825 if (!c_parser_require (parser, CPP_COLON, "expected %<:%>")) |
6930 { | 6826 { |
6931 c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node; | 6827 c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node; |
6932 ret.value = error_mark_node; | 6828 ret.set_error (); |
6933 ret.original_code = ERROR_MARK; | 6829 ret.original_code = ERROR_MARK; |
6934 ret.original_type = NULL; | 6830 ret.original_type = NULL; |
6935 return ret; | 6831 return ret; |
6936 } | 6832 } |
6937 { | 6833 { |
7096 if (POINTER_TYPE_P (type0) \ | 6992 if (POINTER_TYPE_P (type0) \ |
7097 && comptypes (TREE_TYPE (type0), type1) \ | 6993 && comptypes (TREE_TYPE (type0), type1) \ |
7098 && !(TREE_CODE (first_arg) == PARM_DECL \ | 6994 && !(TREE_CODE (first_arg) == PARM_DECL \ |
7099 && C_ARRAY_PARAMETER (first_arg) \ | 6995 && C_ARRAY_PARAMETER (first_arg) \ |
7100 && warn_sizeof_array_argument)) \ | 6996 && warn_sizeof_array_argument)) \ |
7101 if (warning_at (stack[sp].loc, OPT_Wsizeof_pointer_div, \ | 6997 { \ |
7102 "division %<sizeof (%T) / sizeof (%T)%> does " \ | 6998 auto_diagnostic_group d; \ |
7103 "not compute the number of array elements", \ | 6999 if (warning_at (stack[sp].loc, OPT_Wsizeof_pointer_div, \ |
7104 type0, type1)) \ | 7000 "division %<sizeof (%T) / sizeof (%T)%> " \ |
7105 if (DECL_P (first_arg)) \ | 7001 "does not compute the number of array " \ |
7106 inform (DECL_SOURCE_LOCATION (first_arg), \ | 7002 "elements", \ |
7107 "first %<sizeof%> operand was declared here"); \ | 7003 type0, type1)) \ |
7108 } \ | 7004 if (DECL_P (first_arg)) \ |
7005 inform (DECL_SOURCE_LOCATION (first_arg), \ | |
7006 "first %<sizeof%> operand was declared here"); \ | |
7007 } \ | |
7008 } \ | |
7109 break; \ | 7009 break; \ |
7110 default: \ | 7010 default: \ |
7111 break; \ | 7011 break; \ |
7112 } \ | 7012 } \ |
7113 stack[sp - 1].expr \ | 7013 stack[sp - 1].expr \ |
7301 struct c_type_name *type_name; | 7201 struct c_type_name *type_name; |
7302 struct c_expr ret; | 7202 struct c_expr ret; |
7303 struct c_expr expr; | 7203 struct c_expr expr; |
7304 matching_parens parens; | 7204 matching_parens parens; |
7305 parens.consume_open (parser); | 7205 parens.consume_open (parser); |
7306 type_name = c_parser_type_name (parser); | 7206 type_name = c_parser_type_name (parser, true); |
7307 parens.skip_until_found_close (parser); | 7207 parens.skip_until_found_close (parser); |
7308 if (type_name == NULL) | 7208 if (type_name == NULL) |
7309 { | 7209 { |
7310 ret.value = error_mark_node; | 7210 ret.set_error (); |
7311 ret.original_code = ERROR_MARK; | 7211 ret.original_code = ERROR_MARK; |
7312 ret.original_type = NULL; | 7212 ret.original_type = NULL; |
7313 return ret; | 7213 return ret; |
7314 } | 7214 } |
7315 | 7215 |
7317 used_types_insert (type_name->specs->type); | 7217 used_types_insert (type_name->specs->type); |
7318 | 7218 |
7319 if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) | 7219 if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) |
7320 return c_parser_postfix_expression_after_paren_type (parser, type_name, | 7220 return c_parser_postfix_expression_after_paren_type (parser, type_name, |
7321 cast_loc); | 7221 cast_loc); |
7222 if (type_name->specs->alignas_p) | |
7223 error_at (type_name->specs->locations[cdw_alignas], | |
7224 "alignment specified for type name in cast"); | |
7322 { | 7225 { |
7323 location_t expr_loc = c_parser_peek_token (parser)->location; | 7226 location_t expr_loc = c_parser_peek_token (parser)->location; |
7324 expr = c_parser_cast_expression (parser, NULL); | 7227 expr = c_parser_cast_expression (parser, NULL); |
7325 expr = convert_lvalue_to_rvalue (expr_loc, expr, true, true); | 7228 expr = convert_lvalue_to_rvalue (expr_loc, expr, true, true); |
7326 } | 7229 } |
7384 case CPP_PLUS_PLUS: | 7287 case CPP_PLUS_PLUS: |
7385 c_parser_consume_token (parser); | 7288 c_parser_consume_token (parser); |
7386 exp_loc = c_parser_peek_token (parser)->location; | 7289 exp_loc = c_parser_peek_token (parser)->location; |
7387 op = c_parser_cast_expression (parser, NULL); | 7290 op = c_parser_cast_expression (parser, NULL); |
7388 | 7291 |
7389 /* If there is array notations in op, we expand them. */ | 7292 op = default_function_array_read_conversion (exp_loc, op); |
7390 if (flag_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF) | 7293 return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op); |
7391 return fix_array_notation_expr (exp_loc, PREINCREMENT_EXPR, op); | |
7392 else | |
7393 { | |
7394 op = default_function_array_read_conversion (exp_loc, op); | |
7395 return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op); | |
7396 } | |
7397 case CPP_MINUS_MINUS: | 7294 case CPP_MINUS_MINUS: |
7398 c_parser_consume_token (parser); | 7295 c_parser_consume_token (parser); |
7399 exp_loc = c_parser_peek_token (parser)->location; | 7296 exp_loc = c_parser_peek_token (parser)->location; |
7400 op = c_parser_cast_expression (parser, NULL); | 7297 op = c_parser_cast_expression (parser, NULL); |
7401 | 7298 |
7402 /* If there is array notations in op, we expand them. */ | 7299 op = default_function_array_read_conversion (exp_loc, op); |
7403 if (flag_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF) | 7300 return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op); |
7404 return fix_array_notation_expr (exp_loc, PREDECREMENT_EXPR, op); | |
7405 else | |
7406 { | |
7407 op = default_function_array_read_conversion (exp_loc, op); | |
7408 return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op); | |
7409 } | |
7410 case CPP_AND: | 7301 case CPP_AND: |
7411 c_parser_consume_token (parser); | 7302 c_parser_consume_token (parser); |
7412 op = c_parser_cast_expression (parser, NULL); | 7303 op = c_parser_cast_expression (parser, NULL); |
7413 mark_exp_read (op.value); | 7304 mark_exp_read (op.value); |
7414 return parser_build_unary_op (op_loc, ADDR_EXPR, op); | 7305 return parser_build_unary_op (op_loc, ADDR_EXPR, op); |
7532 starting with a compound literal. */ | 7423 starting with a compound literal. */ |
7533 struct c_type_name *type_name; | 7424 struct c_type_name *type_name; |
7534 matching_parens parens; | 7425 matching_parens parens; |
7535 parens.consume_open (parser); | 7426 parens.consume_open (parser); |
7536 expr_loc = c_parser_peek_token (parser)->location; | 7427 expr_loc = c_parser_peek_token (parser)->location; |
7537 type_name = c_parser_type_name (parser); | 7428 type_name = c_parser_type_name (parser, true); |
7538 parens.skip_until_found_close (parser); | 7429 parens.skip_until_found_close (parser); |
7539 finish = parser->tokens_buf[0].location; | 7430 finish = parser->tokens_buf[0].location; |
7540 if (type_name == NULL) | 7431 if (type_name == NULL) |
7541 { | 7432 { |
7542 struct c_expr ret; | 7433 struct c_expr ret; |
7543 c_inhibit_evaluation_warnings--; | 7434 c_inhibit_evaluation_warnings--; |
7544 in_sizeof--; | 7435 in_sizeof--; |
7545 ret.value = error_mark_node; | 7436 ret.set_error (); |
7546 ret.original_code = ERROR_MARK; | 7437 ret.original_code = ERROR_MARK; |
7547 ret.original_type = NULL; | 7438 ret.original_type = NULL; |
7548 return ret; | 7439 return ret; |
7549 } | 7440 } |
7550 if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) | 7441 if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) |
7554 expr_loc); | 7445 expr_loc); |
7555 finish = expr.get_finish (); | 7446 finish = expr.get_finish (); |
7556 goto sizeof_expr; | 7447 goto sizeof_expr; |
7557 } | 7448 } |
7558 /* sizeof ( type-name ). */ | 7449 /* sizeof ( type-name ). */ |
7450 if (type_name->specs->alignas_p) | |
7451 error_at (type_name->specs->locations[cdw_alignas], | |
7452 "alignment specified for type name in %<sizeof%>"); | |
7559 c_inhibit_evaluation_warnings--; | 7453 c_inhibit_evaluation_warnings--; |
7560 in_sizeof--; | 7454 in_sizeof--; |
7561 result = c_expr_sizeof_type (expr_loc, type_name); | 7455 result = c_expr_sizeof_type (expr_loc, type_name); |
7562 } | 7456 } |
7563 else | 7457 else |
7615 struct c_type_name *type_name; | 7509 struct c_type_name *type_name; |
7616 struct c_expr ret; | 7510 struct c_expr ret; |
7617 matching_parens parens; | 7511 matching_parens parens; |
7618 parens.consume_open (parser); | 7512 parens.consume_open (parser); |
7619 loc = c_parser_peek_token (parser)->location; | 7513 loc = c_parser_peek_token (parser)->location; |
7620 type_name = c_parser_type_name (parser); | 7514 type_name = c_parser_type_name (parser, true); |
7621 end_loc = c_parser_peek_token (parser)->location; | 7515 end_loc = c_parser_peek_token (parser)->location; |
7622 parens.skip_until_found_close (parser); | 7516 parens.skip_until_found_close (parser); |
7623 if (type_name == NULL) | 7517 if (type_name == NULL) |
7624 { | 7518 { |
7625 struct c_expr ret; | 7519 struct c_expr ret; |
7626 c_inhibit_evaluation_warnings--; | 7520 c_inhibit_evaluation_warnings--; |
7627 in_alignof--; | 7521 in_alignof--; |
7628 ret.value = error_mark_node; | 7522 ret.set_error (); |
7629 ret.original_code = ERROR_MARK; | 7523 ret.original_code = ERROR_MARK; |
7630 ret.original_type = NULL; | 7524 ret.original_type = NULL; |
7631 return ret; | 7525 return ret; |
7632 } | 7526 } |
7633 if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) | 7527 if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) |
7636 type_name, | 7530 type_name, |
7637 loc); | 7531 loc); |
7638 goto alignof_expr; | 7532 goto alignof_expr; |
7639 } | 7533 } |
7640 /* alignof ( type-name ). */ | 7534 /* alignof ( type-name ). */ |
7535 if (type_name->specs->alignas_p) | |
7536 error_at (type_name->specs->locations[cdw_alignas], | |
7537 "alignment specified for type name in %qE", | |
7538 alignof_spelling); | |
7641 c_inhibit_evaluation_warnings--; | 7539 c_inhibit_evaluation_warnings--; |
7642 in_alignof--; | 7540 in_alignof--; |
7643 ret.value = c_sizeof_or_alignof_type (loc, groktypename (type_name, | 7541 ret.value = c_sizeof_or_alignof_type (loc, groktypename (type_name, |
7644 NULL, NULL), | 7542 NULL, NULL), |
7645 false, is_c11_alignof, 1); | 7543 false, is_c11_alignof, 1); |
7936 } | 7834 } |
7937 | 7835 |
7938 return matched_assoc.expression; | 7836 return matched_assoc.expression; |
7939 } | 7837 } |
7940 | 7838 |
7839 /* Check the validity of a function pointer argument *EXPR (argument | |
7840 position POS) to __builtin_tgmath. Return the number of function | |
7841 arguments if possibly valid; return 0 having reported an error if | |
7842 not valid. */ | |
7843 | |
7844 static unsigned int | |
7845 check_tgmath_function (c_expr *expr, unsigned int pos) | |
7846 { | |
7847 tree type = TREE_TYPE (expr->value); | |
7848 if (!FUNCTION_POINTER_TYPE_P (type)) | |
7849 { | |
7850 error_at (expr->get_location (), | |
7851 "argument %u of %<__builtin_tgmath%> is not a function pointer", | |
7852 pos); | |
7853 return 0; | |
7854 } | |
7855 type = TREE_TYPE (type); | |
7856 if (!prototype_p (type)) | |
7857 { | |
7858 error_at (expr->get_location (), | |
7859 "argument %u of %<__builtin_tgmath%> is unprototyped", pos); | |
7860 return 0; | |
7861 } | |
7862 if (stdarg_p (type)) | |
7863 { | |
7864 error_at (expr->get_location (), | |
7865 "argument %u of %<__builtin_tgmath%> has variable arguments", | |
7866 pos); | |
7867 return 0; | |
7868 } | |
7869 unsigned int nargs = 0; | |
7870 function_args_iterator iter; | |
7871 tree t; | |
7872 FOREACH_FUNCTION_ARGS (type, t, iter) | |
7873 { | |
7874 if (t == void_type_node) | |
7875 break; | |
7876 nargs++; | |
7877 } | |
7878 if (nargs == 0) | |
7879 { | |
7880 error_at (expr->get_location (), | |
7881 "argument %u of %<__builtin_tgmath%> has no arguments", pos); | |
7882 return 0; | |
7883 } | |
7884 return nargs; | |
7885 } | |
7886 | |
7887 /* Ways in which a parameter or return value of a type-generic macro | |
7888 may vary between the different functions the macro may call. */ | |
7889 enum tgmath_parm_kind | |
7890 { | |
7891 tgmath_fixed, tgmath_real, tgmath_complex | |
7892 }; | |
7893 | |
7941 /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2, | 7894 /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2, |
7942 C11 6.5.1-6.5.2). Compound literals aren't handled here; callers have to | 7895 C11 6.5.1-6.5.2). Compound literals aren't handled here; callers have to |
7943 call c_parser_postfix_expression_after_paren_type on encountering them. | 7896 call c_parser_postfix_expression_after_paren_type on encountering them. |
7944 | 7897 |
7945 postfix-expression: | 7898 postfix-expression: |
7976 __builtin_offsetof ( type-name , offsetof-member-designator ) | 7929 __builtin_offsetof ( type-name , offsetof-member-designator ) |
7977 __builtin_choose_expr ( assignment-expression , | 7930 __builtin_choose_expr ( assignment-expression , |
7978 assignment-expression , | 7931 assignment-expression , |
7979 assignment-expression ) | 7932 assignment-expression ) |
7980 __builtin_types_compatible_p ( type-name , type-name ) | 7933 __builtin_types_compatible_p ( type-name , type-name ) |
7934 __builtin_tgmath ( expr-list ) | |
7981 __builtin_complex ( assignment-expression , assignment-expression ) | 7935 __builtin_complex ( assignment-expression , assignment-expression ) |
7982 __builtin_shuffle ( assignment-expression , assignment-expression ) | 7936 __builtin_shuffle ( assignment-expression , assignment-expression ) |
7983 __builtin_shuffle ( assignment-expression , | 7937 __builtin_shuffle ( assignment-expression , |
7984 assignment-expression , | 7938 assignment-expression , |
7985 assignment-expression, ) | 7939 assignment-expression, ) |
8135 static struct c_expr | 8089 static struct c_expr |
8136 c_parser_postfix_expression (c_parser *parser) | 8090 c_parser_postfix_expression (c_parser *parser) |
8137 { | 8091 { |
8138 struct c_expr expr, e1; | 8092 struct c_expr expr, e1; |
8139 struct c_type_name *t1, *t2; | 8093 struct c_type_name *t1, *t2; |
8140 location_t loc = c_parser_peek_token (parser)->location;; | 8094 location_t loc = c_parser_peek_token (parser)->location; |
8141 source_range tok_range = c_parser_peek_token (parser)->get_range (); | 8095 source_range tok_range = c_parser_peek_token (parser)->get_range (); |
8142 expr.original_code = ERROR_MARK; | 8096 expr.original_code = ERROR_MARK; |
8143 expr.original_type = NULL; | 8097 expr.original_type = NULL; |
8144 switch (c_parser_peek_token (parser)->type) | 8098 switch (c_parser_peek_token (parser)->type) |
8145 { | 8099 { |
8150 c_parser_consume_token (parser); | 8104 c_parser_consume_token (parser); |
8151 if (TREE_CODE (expr.value) == FIXED_CST | 8105 if (TREE_CODE (expr.value) == FIXED_CST |
8152 && !targetm.fixed_point_supported_p ()) | 8106 && !targetm.fixed_point_supported_p ()) |
8153 { | 8107 { |
8154 error_at (loc, "fixed-point types not supported for this target"); | 8108 error_at (loc, "fixed-point types not supported for this target"); |
8155 expr.value = error_mark_node; | 8109 expr.set_error (); |
8156 } | 8110 } |
8157 break; | 8111 break; |
8158 case CPP_CHAR: | 8112 case CPP_CHAR: |
8159 case CPP_CHAR16: | 8113 case CPP_CHAR16: |
8160 case CPP_CHAR32: | 8114 case CPP_CHAR32: |
8240 tree stmt; | 8194 tree stmt; |
8241 location_t brace_loc; | 8195 location_t brace_loc; |
8242 c_parser_consume_token (parser); | 8196 c_parser_consume_token (parser); |
8243 brace_loc = c_parser_peek_token (parser)->location; | 8197 brace_loc = c_parser_peek_token (parser)->location; |
8244 c_parser_consume_token (parser); | 8198 c_parser_consume_token (parser); |
8245 if (!building_stmt_list_p ()) | 8199 /* If we've not yet started the current function's statement list, |
8200 or we're in the parameter scope of an old-style function | |
8201 declaration, statement expressions are not allowed. */ | |
8202 if (!building_stmt_list_p () || old_style_parameter_scope ()) | |
8246 { | 8203 { |
8247 error_at (loc, "braced-group within expression allowed " | 8204 error_at (loc, "braced-group within expression allowed " |
8248 "only inside a function"); | 8205 "only inside a function"); |
8249 parser->error = true; | 8206 parser->error = true; |
8250 c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL); | 8207 c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL); |
8534 expr.value | 8491 expr.value |
8535 = comptypes (e1, e2) ? integer_one_node : integer_zero_node; | 8492 = comptypes (e1, e2) ? integer_one_node : integer_zero_node; |
8536 set_c_expr_source_range (&expr, loc, close_paren_loc); | 8493 set_c_expr_source_range (&expr, loc, close_paren_loc); |
8537 } | 8494 } |
8538 break; | 8495 break; |
8496 case RID_BUILTIN_TGMATH: | |
8497 { | |
8498 vec<c_expr_t, va_gc> *cexpr_list; | |
8499 location_t close_paren_loc; | |
8500 | |
8501 c_parser_consume_token (parser); | |
8502 if (!c_parser_get_builtin_args (parser, | |
8503 "__builtin_tgmath", | |
8504 &cexpr_list, false, | |
8505 &close_paren_loc)) | |
8506 { | |
8507 expr.set_error (); | |
8508 break; | |
8509 } | |
8510 | |
8511 if (vec_safe_length (cexpr_list) < 3) | |
8512 { | |
8513 error_at (loc, "too few arguments to %<__builtin_tgmath%>"); | |
8514 expr.set_error (); | |
8515 break; | |
8516 } | |
8517 | |
8518 unsigned int i; | |
8519 c_expr_t *p; | |
8520 FOR_EACH_VEC_ELT (*cexpr_list, i, p) | |
8521 *p = convert_lvalue_to_rvalue (loc, *p, true, true); | |
8522 unsigned int nargs = check_tgmath_function (&(*cexpr_list)[0], 1); | |
8523 if (nargs == 0) | |
8524 { | |
8525 expr.set_error (); | |
8526 break; | |
8527 } | |
8528 if (vec_safe_length (cexpr_list) < nargs) | |
8529 { | |
8530 error_at (loc, "too few arguments to %<__builtin_tgmath%>"); | |
8531 expr.set_error (); | |
8532 break; | |
8533 } | |
8534 unsigned int num_functions = vec_safe_length (cexpr_list) - nargs; | |
8535 if (num_functions < 2) | |
8536 { | |
8537 error_at (loc, "too few arguments to %<__builtin_tgmath%>"); | |
8538 expr.set_error (); | |
8539 break; | |
8540 } | |
8541 | |
8542 /* The first NUM_FUNCTIONS expressions are the function | |
8543 pointers. The remaining NARGS expressions are the | |
8544 arguments that are to be passed to one of those | |
8545 functions, chosen following <tgmath.h> rules. */ | |
8546 for (unsigned int j = 1; j < num_functions; j++) | |
8547 { | |
8548 unsigned int this_nargs | |
8549 = check_tgmath_function (&(*cexpr_list)[j], j + 1); | |
8550 if (this_nargs == 0) | |
8551 { | |
8552 expr.set_error (); | |
8553 goto out; | |
8554 } | |
8555 if (this_nargs != nargs) | |
8556 { | |
8557 error_at ((*cexpr_list)[j].get_location (), | |
8558 "argument %u of %<__builtin_tgmath%> has " | |
8559 "wrong number of arguments", j + 1); | |
8560 expr.set_error (); | |
8561 goto out; | |
8562 } | |
8563 } | |
8564 | |
8565 /* The functions all have the same number of arguments. | |
8566 Determine whether arguments and return types vary in | |
8567 ways permitted for <tgmath.h> functions. */ | |
8568 /* The first entry in each of these vectors is for the | |
8569 return type, subsequent entries for parameter | |
8570 types. */ | |
8571 auto_vec<enum tgmath_parm_kind> parm_kind (nargs + 1); | |
8572 auto_vec<tree> parm_first (nargs + 1); | |
8573 auto_vec<bool> parm_complex (nargs + 1); | |
8574 auto_vec<bool> parm_varies (nargs + 1); | |
8575 tree first_type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[0].value)); | |
8576 tree first_ret = TYPE_MAIN_VARIANT (TREE_TYPE (first_type)); | |
8577 parm_first.quick_push (first_ret); | |
8578 parm_complex.quick_push (TREE_CODE (first_ret) == COMPLEX_TYPE); | |
8579 parm_varies.quick_push (false); | |
8580 function_args_iterator iter; | |
8581 tree t; | |
8582 unsigned int argpos; | |
8583 FOREACH_FUNCTION_ARGS (first_type, t, iter) | |
8584 { | |
8585 if (t == void_type_node) | |
8586 break; | |
8587 parm_first.quick_push (TYPE_MAIN_VARIANT (t)); | |
8588 parm_complex.quick_push (TREE_CODE (t) == COMPLEX_TYPE); | |
8589 parm_varies.quick_push (false); | |
8590 } | |
8591 for (unsigned int j = 1; j < num_functions; j++) | |
8592 { | |
8593 tree type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[j].value)); | |
8594 tree ret = TYPE_MAIN_VARIANT (TREE_TYPE (type)); | |
8595 if (ret != parm_first[0]) | |
8596 { | |
8597 parm_varies[0] = true; | |
8598 if (!SCALAR_FLOAT_TYPE_P (parm_first[0]) | |
8599 && !COMPLEX_FLOAT_TYPE_P (parm_first[0])) | |
8600 { | |
8601 error_at ((*cexpr_list)[0].get_location (), | |
8602 "invalid type-generic return type for " | |
8603 "argument %u of %<__builtin_tgmath%>", | |
8604 1); | |
8605 expr.set_error (); | |
8606 goto out; | |
8607 } | |
8608 if (!SCALAR_FLOAT_TYPE_P (ret) | |
8609 && !COMPLEX_FLOAT_TYPE_P (ret)) | |
8610 { | |
8611 error_at ((*cexpr_list)[j].get_location (), | |
8612 "invalid type-generic return type for " | |
8613 "argument %u of %<__builtin_tgmath%>", | |
8614 j + 1); | |
8615 expr.set_error (); | |
8616 goto out; | |
8617 } | |
8618 } | |
8619 if (TREE_CODE (ret) == COMPLEX_TYPE) | |
8620 parm_complex[0] = true; | |
8621 argpos = 1; | |
8622 FOREACH_FUNCTION_ARGS (type, t, iter) | |
8623 { | |
8624 if (t == void_type_node) | |
8625 break; | |
8626 t = TYPE_MAIN_VARIANT (t); | |
8627 if (t != parm_first[argpos]) | |
8628 { | |
8629 parm_varies[argpos] = true; | |
8630 if (!SCALAR_FLOAT_TYPE_P (parm_first[argpos]) | |
8631 && !COMPLEX_FLOAT_TYPE_P (parm_first[argpos])) | |
8632 { | |
8633 error_at ((*cexpr_list)[0].get_location (), | |
8634 "invalid type-generic type for " | |
8635 "argument %u of argument %u of " | |
8636 "%<__builtin_tgmath%>", argpos, 1); | |
8637 expr.set_error (); | |
8638 goto out; | |
8639 } | |
8640 if (!SCALAR_FLOAT_TYPE_P (t) | |
8641 && !COMPLEX_FLOAT_TYPE_P (t)) | |
8642 { | |
8643 error_at ((*cexpr_list)[j].get_location (), | |
8644 "invalid type-generic type for " | |
8645 "argument %u of argument %u of " | |
8646 "%<__builtin_tgmath%>", argpos, j + 1); | |
8647 expr.set_error (); | |
8648 goto out; | |
8649 } | |
8650 } | |
8651 if (TREE_CODE (t) == COMPLEX_TYPE) | |
8652 parm_complex[argpos] = true; | |
8653 argpos++; | |
8654 } | |
8655 } | |
8656 enum tgmath_parm_kind max_variation = tgmath_fixed; | |
8657 for (unsigned int j = 0; j <= nargs; j++) | |
8658 { | |
8659 enum tgmath_parm_kind this_kind; | |
8660 if (parm_varies[j]) | |
8661 { | |
8662 if (parm_complex[j]) | |
8663 max_variation = this_kind = tgmath_complex; | |
8664 else | |
8665 { | |
8666 this_kind = tgmath_real; | |
8667 if (max_variation != tgmath_complex) | |
8668 max_variation = tgmath_real; | |
8669 } | |
8670 } | |
8671 else | |
8672 this_kind = tgmath_fixed; | |
8673 parm_kind.quick_push (this_kind); | |
8674 } | |
8675 if (max_variation == tgmath_fixed) | |
8676 { | |
8677 error_at (loc, "function arguments of %<__builtin_tgmath%> " | |
8678 "all have the same type"); | |
8679 expr.set_error (); | |
8680 break; | |
8681 } | |
8682 | |
8683 /* Identify a parameter (not the return type) that varies, | |
8684 including with complex types if any variation includes | |
8685 complex types; there must be at least one such | |
8686 parameter. */ | |
8687 unsigned int tgarg = 0; | |
8688 for (unsigned int j = 1; j <= nargs; j++) | |
8689 if (parm_kind[j] == max_variation) | |
8690 { | |
8691 tgarg = j; | |
8692 break; | |
8693 } | |
8694 if (tgarg == 0) | |
8695 { | |
8696 error_at (loc, "function arguments of %<__builtin_tgmath%> " | |
8697 "lack type-generic parameter"); | |
8698 expr.set_error (); | |
8699 break; | |
8700 } | |
8701 | |
8702 /* Determine the type of the relevant parameter for each | |
8703 function. */ | |
8704 auto_vec<tree> tg_type (num_functions); | |
8705 for (unsigned int j = 0; j < num_functions; j++) | |
8706 { | |
8707 tree type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[j].value)); | |
8708 argpos = 1; | |
8709 FOREACH_FUNCTION_ARGS (type, t, iter) | |
8710 { | |
8711 if (argpos == tgarg) | |
8712 { | |
8713 tg_type.quick_push (TYPE_MAIN_VARIANT (t)); | |
8714 break; | |
8715 } | |
8716 argpos++; | |
8717 } | |
8718 } | |
8719 | |
8720 /* Verify that the corresponding types are different for | |
8721 all the listed functions. Also determine whether all | |
8722 the types are complex, whether all the types are | |
8723 standard or binary, and whether all the types are | |
8724 decimal. */ | |
8725 bool all_complex = true; | |
8726 bool all_binary = true; | |
8727 bool all_decimal = true; | |
8728 hash_set<tree> tg_types; | |
8729 FOR_EACH_VEC_ELT (tg_type, i, t) | |
8730 { | |
8731 if (TREE_CODE (t) == COMPLEX_TYPE) | |
8732 all_decimal = false; | |
8733 else | |
8734 { | |
8735 all_complex = false; | |
8736 if (DECIMAL_FLOAT_TYPE_P (t)) | |
8737 all_binary = false; | |
8738 else | |
8739 all_decimal = false; | |
8740 } | |
8741 if (tg_types.add (t)) | |
8742 { | |
8743 error_at ((*cexpr_list)[i].get_location (), | |
8744 "duplicate type-generic parameter type for " | |
8745 "function argument %u of %<__builtin_tgmath%>", | |
8746 i + 1); | |
8747 expr.set_error (); | |
8748 goto out; | |
8749 } | |
8750 } | |
8751 | |
8752 /* Verify that other parameters and the return type whose | |
8753 types vary have their types varying in the correct | |
8754 way. */ | |
8755 for (unsigned int j = 0; j < num_functions; j++) | |
8756 { | |
8757 tree exp_type = tg_type[j]; | |
8758 tree exp_real_type = exp_type; | |
8759 if (TREE_CODE (exp_type) == COMPLEX_TYPE) | |
8760 exp_real_type = TREE_TYPE (exp_type); | |
8761 tree type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[j].value)); | |
8762 tree ret = TYPE_MAIN_VARIANT (TREE_TYPE (type)); | |
8763 if ((parm_kind[0] == tgmath_complex && ret != exp_type) | |
8764 || (parm_kind[0] == tgmath_real && ret != exp_real_type)) | |
8765 { | |
8766 error_at ((*cexpr_list)[j].get_location (), | |
8767 "bad return type for function argument %u " | |
8768 "of %<__builtin_tgmath%>", j + 1); | |
8769 expr.set_error (); | |
8770 goto out; | |
8771 } | |
8772 argpos = 1; | |
8773 FOREACH_FUNCTION_ARGS (type, t, iter) | |
8774 { | |
8775 if (t == void_type_node) | |
8776 break; | |
8777 t = TYPE_MAIN_VARIANT (t); | |
8778 if ((parm_kind[argpos] == tgmath_complex | |
8779 && t != exp_type) | |
8780 || (parm_kind[argpos] == tgmath_real | |
8781 && t != exp_real_type)) | |
8782 { | |
8783 error_at ((*cexpr_list)[j].get_location (), | |
8784 "bad type for argument %u of " | |
8785 "function argument %u of " | |
8786 "%<__builtin_tgmath%>", argpos, j + 1); | |
8787 expr.set_error (); | |
8788 goto out; | |
8789 } | |
8790 argpos++; | |
8791 } | |
8792 } | |
8793 | |
8794 /* The functions listed are a valid set of functions for a | |
8795 <tgmath.h> macro to select between. Identify the | |
8796 matching function, if any. First, the argument types | |
8797 must be combined following <tgmath.h> rules. Integer | |
8798 types are treated as _Decimal64 if any type-generic | |
8799 argument is decimal, or if the only alternatives for | |
8800 type-generic arguments are of decimal types, and are | |
8801 otherwise treated as double (or _Complex double for | |
8802 complex integer types, or _Float64 or _Complex _Float64 | |
8803 if all the return types are the same _FloatN or | |
8804 _FloatNx type). After that adjustment, types are | |
8805 combined following the usual arithmetic conversions. | |
8806 If the function only accepts complex arguments, a | |
8807 complex type is produced. */ | |
8808 bool arg_complex = all_complex; | |
8809 bool arg_binary = all_binary; | |
8810 bool arg_int_decimal = all_decimal; | |
8811 for (unsigned int j = 1; j <= nargs; j++) | |
8812 { | |
8813 if (parm_kind[j] == tgmath_fixed) | |
8814 continue; | |
8815 c_expr_t *ce = &(*cexpr_list)[num_functions + j - 1]; | |
8816 tree type = TREE_TYPE (ce->value); | |
8817 if (!INTEGRAL_TYPE_P (type) | |
8818 && !SCALAR_FLOAT_TYPE_P (type) | |
8819 && TREE_CODE (type) != COMPLEX_TYPE) | |
8820 { | |
8821 error_at (ce->get_location (), | |
8822 "invalid type of argument %u of type-generic " | |
8823 "function", j); | |
8824 expr.set_error (); | |
8825 goto out; | |
8826 } | |
8827 if (DECIMAL_FLOAT_TYPE_P (type)) | |
8828 { | |
8829 arg_int_decimal = true; | |
8830 if (all_complex) | |
8831 { | |
8832 error_at (ce->get_location (), | |
8833 "decimal floating-point argument %u to " | |
8834 "complex-only type-generic function", j); | |
8835 expr.set_error (); | |
8836 goto out; | |
8837 } | |
8838 else if (all_binary) | |
8839 { | |
8840 error_at (ce->get_location (), | |
8841 "decimal floating-point argument %u to " | |
8842 "binary-only type-generic function", j); | |
8843 expr.set_error (); | |
8844 goto out; | |
8845 } | |
8846 else if (arg_complex) | |
8847 { | |
8848 error_at (ce->get_location (), | |
8849 "both complex and decimal floating-point " | |
8850 "arguments to type-generic function"); | |
8851 expr.set_error (); | |
8852 goto out; | |
8853 } | |
8854 else if (arg_binary) | |
8855 { | |
8856 error_at (ce->get_location (), | |
8857 "both binary and decimal floating-point " | |
8858 "arguments to type-generic function"); | |
8859 expr.set_error (); | |
8860 goto out; | |
8861 } | |
8862 } | |
8863 else if (TREE_CODE (type) == COMPLEX_TYPE) | |
8864 { | |
8865 arg_complex = true; | |
8866 if (COMPLEX_FLOAT_TYPE_P (type)) | |
8867 arg_binary = true; | |
8868 if (all_decimal) | |
8869 { | |
8870 error_at (ce->get_location (), | |
8871 "complex argument %u to " | |
8872 "decimal-only type-generic function", j); | |
8873 expr.set_error (); | |
8874 goto out; | |
8875 } | |
8876 else if (arg_int_decimal) | |
8877 { | |
8878 error_at (ce->get_location (), | |
8879 "both complex and decimal floating-point " | |
8880 "arguments to type-generic function"); | |
8881 expr.set_error (); | |
8882 goto out; | |
8883 } | |
8884 } | |
8885 else if (SCALAR_FLOAT_TYPE_P (type)) | |
8886 { | |
8887 arg_binary = true; | |
8888 if (all_decimal) | |
8889 { | |
8890 error_at (ce->get_location (), | |
8891 "binary argument %u to " | |
8892 "decimal-only type-generic function", j); | |
8893 expr.set_error (); | |
8894 goto out; | |
8895 } | |
8896 else if (arg_int_decimal) | |
8897 { | |
8898 error_at (ce->get_location (), | |
8899 "both binary and decimal floating-point " | |
8900 "arguments to type-generic function"); | |
8901 expr.set_error (); | |
8902 goto out; | |
8903 } | |
8904 } | |
8905 } | |
8906 /* For a macro rounding its result to a narrower type, map | |
8907 integer types to _Float64 not double if the return type | |
8908 is a _FloatN or _FloatNx type. */ | |
8909 bool arg_int_float64 = false; | |
8910 if (parm_kind[0] == tgmath_fixed | |
8911 && SCALAR_FLOAT_TYPE_P (parm_first[0]) | |
8912 && float64_type_node != NULL_TREE) | |
8913 for (unsigned int j = 0; j < NUM_FLOATN_NX_TYPES; j++) | |
8914 if (parm_first[0] == FLOATN_TYPE_NODE (j)) | |
8915 { | |
8916 arg_int_float64 = true; | |
8917 break; | |
8918 } | |
8919 tree arg_real = NULL_TREE; | |
8920 for (unsigned int j = 1; j <= nargs; j++) | |
8921 { | |
8922 if (parm_kind[j] == tgmath_fixed) | |
8923 continue; | |
8924 c_expr_t *ce = &(*cexpr_list)[num_functions + j - 1]; | |
8925 tree type = TYPE_MAIN_VARIANT (TREE_TYPE (ce->value)); | |
8926 if (TREE_CODE (type) == COMPLEX_TYPE) | |
8927 type = TREE_TYPE (type); | |
8928 if (INTEGRAL_TYPE_P (type)) | |
8929 type = (arg_int_decimal | |
8930 ? dfloat64_type_node | |
8931 : arg_int_float64 | |
8932 ? float64_type_node | |
8933 : double_type_node); | |
8934 if (arg_real == NULL_TREE) | |
8935 arg_real = type; | |
8936 else | |
8937 arg_real = common_type (arg_real, type); | |
8938 if (arg_real == error_mark_node) | |
8939 { | |
8940 expr.set_error (); | |
8941 goto out; | |
8942 } | |
8943 } | |
8944 tree arg_type = (arg_complex | |
8945 ? build_complex_type (arg_real) | |
8946 : arg_real); | |
8947 | |
8948 /* Look for a function to call with type-generic parameter | |
8949 type ARG_TYPE. */ | |
8950 c_expr_t *fn = NULL; | |
8951 for (unsigned int j = 0; j < num_functions; j++) | |
8952 { | |
8953 if (tg_type[j] == arg_type) | |
8954 { | |
8955 fn = &(*cexpr_list)[j]; | |
8956 break; | |
8957 } | |
8958 } | |
8959 if (fn == NULL | |
8960 && parm_kind[0] == tgmath_fixed | |
8961 && SCALAR_FLOAT_TYPE_P (parm_first[0])) | |
8962 { | |
8963 /* Presume this is a macro that rounds its result to a | |
8964 narrower type, and look for the first function with | |
8965 at least the range and precision of the argument | |
8966 type. */ | |
8967 for (unsigned int j = 0; j < num_functions; j++) | |
8968 { | |
8969 if (arg_complex | |
8970 != (TREE_CODE (tg_type[j]) == COMPLEX_TYPE)) | |
8971 continue; | |
8972 tree real_tg_type = (arg_complex | |
8973 ? TREE_TYPE (tg_type[j]) | |
8974 : tg_type[j]); | |
8975 if (DECIMAL_FLOAT_TYPE_P (arg_real) | |
8976 != DECIMAL_FLOAT_TYPE_P (real_tg_type)) | |
8977 continue; | |
8978 scalar_float_mode arg_mode | |
8979 = SCALAR_FLOAT_TYPE_MODE (arg_real); | |
8980 scalar_float_mode tg_mode | |
8981 = SCALAR_FLOAT_TYPE_MODE (real_tg_type); | |
8982 const real_format *arg_fmt = REAL_MODE_FORMAT (arg_mode); | |
8983 const real_format *tg_fmt = REAL_MODE_FORMAT (tg_mode); | |
8984 if (arg_fmt->b == tg_fmt->b | |
8985 && arg_fmt->p <= tg_fmt->p | |
8986 && arg_fmt->emax <= tg_fmt->emax | |
8987 && (arg_fmt->emin - arg_fmt->p | |
8988 >= tg_fmt->emin - tg_fmt->p)) | |
8989 { | |
8990 fn = &(*cexpr_list)[j]; | |
8991 break; | |
8992 } | |
8993 } | |
8994 } | |
8995 if (fn == NULL) | |
8996 { | |
8997 error_at (loc, "no matching function for type-generic call"); | |
8998 expr.set_error (); | |
8999 break; | |
9000 } | |
9001 | |
9002 /* Construct a call to FN. */ | |
9003 vec<tree, va_gc> *args; | |
9004 vec_alloc (args, nargs); | |
9005 vec<tree, va_gc> *origtypes; | |
9006 vec_alloc (origtypes, nargs); | |
9007 auto_vec<location_t> arg_loc (nargs); | |
9008 for (unsigned int j = 0; j < nargs; j++) | |
9009 { | |
9010 c_expr_t *ce = &(*cexpr_list)[num_functions + j]; | |
9011 args->quick_push (ce->value); | |
9012 arg_loc.quick_push (ce->get_location ()); | |
9013 origtypes->quick_push (ce->original_type); | |
9014 } | |
9015 expr.value = c_build_function_call_vec (loc, arg_loc, fn->value, | |
9016 args, origtypes); | |
9017 set_c_expr_source_range (&expr, loc, close_paren_loc); | |
9018 break; | |
9019 } | |
8539 case RID_BUILTIN_CALL_WITH_STATIC_CHAIN: | 9020 case RID_BUILTIN_CALL_WITH_STATIC_CHAIN: |
8540 { | 9021 { |
8541 vec<c_expr_t, va_gc> *cexpr_list; | 9022 vec<c_expr_t, va_gc> *cexpr_list; |
8542 c_expr_t *e2_p; | 9023 c_expr_t *e2_p; |
8543 tree chain_value; | 9024 tree chain_value; |
8837 break; | 9318 break; |
8838 #endif //noCbC | 9319 #endif //noCbC |
8839 case RID_GENERIC: | 9320 case RID_GENERIC: |
8840 expr = c_parser_generic_selection (parser); | 9321 expr = c_parser_generic_selection (parser); |
8841 break; | 9322 break; |
8842 case RID_CILK_SPAWN: | |
8843 c_parser_consume_token (parser); | |
8844 if (!flag_cilkplus) | |
8845 { | |
8846 error_at (loc, "-fcilkplus must be enabled to use " | |
8847 "%<_Cilk_spawn%>"); | |
8848 expr = c_parser_cast_expression (parser, NULL); | |
8849 expr.set_error (); | |
8850 } | |
8851 else if (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN) | |
8852 { | |
8853 error_at (loc, "consecutive %<_Cilk_spawn%> keywords " | |
8854 "are not permitted"); | |
8855 /* Now flush out all the _Cilk_spawns. */ | |
8856 while (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN) | |
8857 c_parser_consume_token (parser); | |
8858 expr = c_parser_cast_expression (parser, NULL); | |
8859 } | |
8860 else | |
8861 { | |
8862 expr = c_parser_cast_expression (parser, NULL); | |
8863 expr.value = build_cilk_spawn (loc, expr.value); | |
8864 } | |
8865 break; | |
8866 default: | 9323 default: |
8867 c_parser_error (parser, "expected expression"); | 9324 c_parser_error (parser, "expected expression"); |
8868 expr.set_error (); | 9325 expr.set_error (); |
8869 break; | 9326 break; |
8870 } | 9327 } |
8888 default: | 9345 default: |
8889 c_parser_error (parser, "expected expression"); | 9346 c_parser_error (parser, "expected expression"); |
8890 expr.set_error (); | 9347 expr.set_error (); |
8891 break; | 9348 break; |
8892 } | 9349 } |
9350 out: | |
8893 return c_parser_postfix_expression_after_primary | 9351 return c_parser_postfix_expression_after_primary |
8894 (parser, EXPR_LOC_OR_LOC (expr.value, loc), expr); | 9352 (parser, EXPR_LOC_OR_LOC (expr.value, loc), expr); |
8895 } | 9353 } |
8896 | 9354 |
8897 /* Parse a postfix expression after a parenthesized type name: the | 9355 /* Parse a postfix expression after a parenthesized type name: the |
8941 pedwarn_c90 (start_loc, OPT_Wpedantic, "ISO C90 forbids compound literals"); | 9399 pedwarn_c90 (start_loc, OPT_Wpedantic, "ISO C90 forbids compound literals"); |
8942 non_const = ((init.value && TREE_CODE (init.value) == CONSTRUCTOR) | 9400 non_const = ((init.value && TREE_CODE (init.value) == CONSTRUCTOR) |
8943 ? CONSTRUCTOR_NON_CONST (init.value) | 9401 ? CONSTRUCTOR_NON_CONST (init.value) |
8944 : init.original_code == C_MAYBE_CONST_EXPR); | 9402 : init.original_code == C_MAYBE_CONST_EXPR); |
8945 non_const |= !type_expr_const; | 9403 non_const |= !type_expr_const; |
8946 expr.value = build_compound_literal (start_loc, type, init.value, non_const); | 9404 unsigned int alignas_align = 0; |
9405 if (type != error_mark_node | |
9406 && type_name->specs->align_log != -1) | |
9407 { | |
9408 alignas_align = 1U << type_name->specs->align_log; | |
9409 if (alignas_align < min_align_of_type (type)) | |
9410 { | |
9411 error_at (type_name->specs->locations[cdw_alignas], | |
9412 "%<_Alignas%> specifiers cannot reduce " | |
9413 "alignment of compound literal"); | |
9414 alignas_align = 0; | |
9415 } | |
9416 } | |
9417 expr.value = build_compound_literal (start_loc, type, init.value, non_const, | |
9418 alignas_align); | |
8947 set_c_expr_source_range (&expr, init.src_range); | 9419 set_c_expr_source_range (&expr, init.src_range); |
8948 expr.original_code = ERROR_MARK; | 9420 expr.original_code = ERROR_MARK; |
8949 expr.original_type = NULL; | 9421 expr.original_type = NULL; |
8950 if (type != error_mark_node | 9422 if (type != error_mark_node |
8951 && expr.value != error_mark_node | 9423 && expr.value != error_mark_node |
8972 static bool | 9444 static bool |
8973 sizeof_ptr_memacc_comptypes (tree type1, tree type2) | 9445 sizeof_ptr_memacc_comptypes (tree type1, tree type2) |
8974 { | 9446 { |
8975 return comptypes (type1, type2) == 1; | 9447 return comptypes (type1, type2) == 1; |
8976 } | 9448 } |
9449 | |
9450 /* Warn for patterns where abs-like function appears to be used incorrectly, | |
9451 gracefully ignore any non-abs-like function. The warning location should | |
9452 be LOC. FNDECL is the declaration of called function, it must be a | |
9453 BUILT_IN_NORMAL function. ARG is the first and only argument of the | |
9454 call. */ | |
9455 | |
9456 static void | |
9457 warn_for_abs (location_t loc, tree fndecl, tree arg) | |
9458 { | |
9459 tree atype = TREE_TYPE (arg); | |
9460 | |
9461 /* Casts from pointers (and thus arrays and fndecls) will generate | |
9462 -Wint-conversion warnings. Most other wrong types hopefully lead to type | |
9463 mismatch errors. TODO: Think about what to do with FIXED_POINT_TYPE_P | |
9464 types and possibly other exotic types. */ | |
9465 if (!INTEGRAL_TYPE_P (atype) | |
9466 && !SCALAR_FLOAT_TYPE_P (atype) | |
9467 && TREE_CODE (atype) != COMPLEX_TYPE) | |
9468 return; | |
9469 | |
9470 enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); | |
9471 | |
9472 switch (fcode) | |
9473 { | |
9474 case BUILT_IN_ABS: | |
9475 case BUILT_IN_LABS: | |
9476 case BUILT_IN_LLABS: | |
9477 case BUILT_IN_IMAXABS: | |
9478 if (!INTEGRAL_TYPE_P (atype)) | |
9479 { | |
9480 if (SCALAR_FLOAT_TYPE_P (atype)) | |
9481 warning_at (loc, OPT_Wabsolute_value, | |
9482 "using integer absolute value function %qD when " | |
9483 "argument is of floating point type %qT", | |
9484 fndecl, atype); | |
9485 else if (TREE_CODE (atype) == COMPLEX_TYPE) | |
9486 warning_at (loc, OPT_Wabsolute_value, | |
9487 "using integer absolute value function %qD when " | |
9488 "argument is of complex type %qT", fndecl, atype); | |
9489 else | |
9490 gcc_unreachable (); | |
9491 return; | |
9492 } | |
9493 if (TYPE_UNSIGNED (atype)) | |
9494 warning_at (loc, OPT_Wabsolute_value, | |
9495 "taking the absolute value of unsigned type %qT " | |
9496 "has no effect", atype); | |
9497 break; | |
9498 | |
9499 CASE_FLT_FN (BUILT_IN_FABS): | |
9500 CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS): | |
9501 if (!SCALAR_FLOAT_TYPE_P (atype) | |
9502 || DECIMAL_FLOAT_MODE_P (TYPE_MODE (atype))) | |
9503 { | |
9504 if (INTEGRAL_TYPE_P (atype)) | |
9505 warning_at (loc, OPT_Wabsolute_value, | |
9506 "using floating point absolute value function %qD " | |
9507 "when argument is of integer type %qT", fndecl, atype); | |
9508 else if (DECIMAL_FLOAT_TYPE_P (atype)) | |
9509 warning_at (loc, OPT_Wabsolute_value, | |
9510 "using floating point absolute value function %qD " | |
9511 "when argument is of decimal floating point type %qT", | |
9512 fndecl, atype); | |
9513 else if (TREE_CODE (atype) == COMPLEX_TYPE) | |
9514 warning_at (loc, OPT_Wabsolute_value, | |
9515 "using floating point absolute value function %qD when " | |
9516 "argument is of complex type %qT", fndecl, atype); | |
9517 else | |
9518 gcc_unreachable (); | |
9519 return; | |
9520 } | |
9521 break; | |
9522 | |
9523 CASE_FLT_FN (BUILT_IN_CABS): | |
9524 if (TREE_CODE (atype) != COMPLEX_TYPE) | |
9525 { | |
9526 if (INTEGRAL_TYPE_P (atype)) | |
9527 warning_at (loc, OPT_Wabsolute_value, | |
9528 "using complex absolute value function %qD when " | |
9529 "argument is of integer type %qT", fndecl, atype); | |
9530 else if (SCALAR_FLOAT_TYPE_P (atype)) | |
9531 warning_at (loc, OPT_Wabsolute_value, | |
9532 "using complex absolute value function %qD when " | |
9533 "argument is of floating point type %qT", | |
9534 fndecl, atype); | |
9535 else | |
9536 gcc_unreachable (); | |
9537 | |
9538 return; | |
9539 } | |
9540 break; | |
9541 | |
9542 case BUILT_IN_FABSD32: | |
9543 case BUILT_IN_FABSD64: | |
9544 case BUILT_IN_FABSD128: | |
9545 if (!DECIMAL_FLOAT_TYPE_P (atype)) | |
9546 { | |
9547 if (INTEGRAL_TYPE_P (atype)) | |
9548 warning_at (loc, OPT_Wabsolute_value, | |
9549 "using decimal floating point absolute value " | |
9550 "function %qD when argument is of integer type %qT", | |
9551 fndecl, atype); | |
9552 else if (SCALAR_FLOAT_TYPE_P (atype)) | |
9553 warning_at (loc, OPT_Wabsolute_value, | |
9554 "using decimal floating point absolute value " | |
9555 "function %qD when argument is of floating point " | |
9556 "type %qT", fndecl, atype); | |
9557 else if (TREE_CODE (atype) == COMPLEX_TYPE) | |
9558 warning_at (loc, OPT_Wabsolute_value, | |
9559 "using decimal floating point absolute value " | |
9560 "function %qD when argument is of complex type %qT", | |
9561 fndecl, atype); | |
9562 else | |
9563 gcc_unreachable (); | |
9564 return; | |
9565 } | |
9566 break; | |
9567 | |
9568 default: | |
9569 return; | |
9570 } | |
9571 | |
9572 if (!TYPE_ARG_TYPES (TREE_TYPE (fndecl))) | |
9573 return; | |
9574 | |
9575 tree ftype = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))); | |
9576 if (TREE_CODE (atype) == COMPLEX_TYPE) | |
9577 { | |
9578 gcc_assert (TREE_CODE (ftype) == COMPLEX_TYPE); | |
9579 atype = TREE_TYPE (atype); | |
9580 ftype = TREE_TYPE (ftype); | |
9581 } | |
9582 | |
9583 if (TYPE_PRECISION (ftype) < TYPE_PRECISION (atype)) | |
9584 warning_at (loc, OPT_Wabsolute_value, | |
9585 "absolute value function %qD given an argument of type %qT " | |
9586 "but has parameter of type %qT which may cause truncation " | |
9587 "of value", fndecl, atype, ftype); | |
9588 } | |
9589 | |
8977 | 9590 |
8978 /* Parse a postfix expression after the initial primary or compound | 9591 /* Parse a postfix expression after the initial primary or compound |
8979 literal; that is, parse a series of postfix operators. | 9592 literal; that is, parse a series of postfix operators. |
8980 | 9593 |
8981 EXPR_LOC is the location of the primary expression. */ | 9594 EXPR_LOC is the location of the primary expression. */ |
9003 switch (c_parser_peek_token (parser)->type) | 9616 switch (c_parser_peek_token (parser)->type) |
9004 { | 9617 { |
9005 case CPP_OPEN_SQUARE: | 9618 case CPP_OPEN_SQUARE: |
9006 /* Array reference. */ | 9619 /* Array reference. */ |
9007 c_parser_consume_token (parser); | 9620 c_parser_consume_token (parser); |
9008 if (flag_cilkplus | 9621 idx = c_parser_expression (parser).value; |
9009 && c_parser_peek_token (parser)->type == CPP_COLON) | 9622 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, |
9010 /* If we are here, then we have something like this: | 9623 "expected %<]%>"); |
9011 Array [ : ] | 9624 start = expr.get_start (); |
9012 */ | 9625 finish = parser->tokens_buf[0].location; |
9013 expr.value = c_parser_array_notation (expr_loc, parser, NULL_TREE, | 9626 expr.value = build_array_ref (op_loc, expr.value, idx); |
9014 expr.value); | 9627 set_c_expr_source_range (&expr, start, finish); |
9015 else | |
9016 { | |
9017 idx = c_parser_expression (parser).value; | |
9018 /* Here we have 3 options: | |
9019 1. Array [EXPR] -- Normal Array call. | |
9020 2. Array [EXPR : EXPR] -- Array notation without stride. | |
9021 3. Array [EXPR : EXPR : EXPR] -- Array notation with stride. | |
9022 | |
9023 For 1, we just handle it just like a normal array expression. | |
9024 For 2 and 3 we handle it like we handle array notations. The | |
9025 idx value we have above becomes the initial/start index. | |
9026 */ | |
9027 if (flag_cilkplus | |
9028 && c_parser_peek_token (parser)->type == CPP_COLON) | |
9029 expr.value = c_parser_array_notation (expr_loc, parser, idx, | |
9030 expr.value); | |
9031 else | |
9032 { | |
9033 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, | |
9034 "expected %<]%>"); | |
9035 start = expr.get_start (); | |
9036 finish = parser->tokens_buf[0].location; | |
9037 expr.value = build_array_ref (op_loc, expr.value, idx); | |
9038 set_c_expr_source_range (&expr, start, finish); | |
9039 } | |
9040 } | |
9041 expr.original_code = ERROR_MARK; | 9628 expr.original_code = ERROR_MARK; |
9042 expr.original_type = NULL; | 9629 expr.original_type = NULL; |
9043 break; | 9630 break; |
9044 case CPP_OPEN_PAREN: | 9631 case CPP_OPEN_PAREN: |
9045 /* Function call. */ | 9632 /* Function call. */ |
9063 if (warn_sizeof_pointer_memaccess) | 9650 if (warn_sizeof_pointer_memaccess) |
9064 sizeof_pointer_memaccess_warning (sizeof_arg_loc, | 9651 sizeof_pointer_memaccess_warning (sizeof_arg_loc, |
9065 expr.value, exprlist, | 9652 expr.value, exprlist, |
9066 sizeof_arg, | 9653 sizeof_arg, |
9067 sizeof_ptr_memacc_comptypes); | 9654 sizeof_ptr_memacc_comptypes); |
9068 if (TREE_CODE (expr.value) == FUNCTION_DECL | 9655 if (TREE_CODE (expr.value) == FUNCTION_DECL) |
9069 && DECL_BUILT_IN_CLASS (expr.value) == BUILT_IN_NORMAL | |
9070 && DECL_FUNCTION_CODE (expr.value) == BUILT_IN_MEMSET | |
9071 && vec_safe_length (exprlist) == 3) | |
9072 { | 9656 { |
9073 tree arg0 = (*exprlist)[0]; | 9657 if (fndecl_built_in_p (expr.value, BUILT_IN_MEMSET) |
9074 tree arg2 = (*exprlist)[2]; | 9658 && vec_safe_length (exprlist) == 3) |
9075 warn_for_memset (expr_loc, arg0, arg2, literal_zero_mask); | 9659 { |
9660 tree arg0 = (*exprlist)[0]; | |
9661 tree arg2 = (*exprlist)[2]; | |
9662 warn_for_memset (expr_loc, arg0, arg2, literal_zero_mask); | |
9663 } | |
9664 if (warn_absolute_value | |
9665 && fndecl_built_in_p (expr.value, BUILT_IN_NORMAL) | |
9666 && vec_safe_length (exprlist) == 1) | |
9667 warn_for_abs (expr_loc, expr.value, (*exprlist)[0]); | |
9076 } | 9668 } |
9077 | 9669 |
9078 start = expr.get_start (); | 9670 start = expr.get_start (); |
9079 finish = parser->tokens_buf[0].get_finish (); | 9671 finish = parser->tokens_buf[0].get_finish (); |
9080 expr.value | 9672 expr.value |
9083 set_c_expr_source_range (&expr, start, finish); | 9675 set_c_expr_source_range (&expr, start, finish); |
9084 | 9676 |
9085 expr.original_code = ERROR_MARK; | 9677 expr.original_code = ERROR_MARK; |
9086 if (TREE_CODE (expr.value) == INTEGER_CST | 9678 if (TREE_CODE (expr.value) == INTEGER_CST |
9087 && TREE_CODE (orig_expr.value) == FUNCTION_DECL | 9679 && TREE_CODE (orig_expr.value) == FUNCTION_DECL |
9088 && DECL_BUILT_IN_CLASS (orig_expr.value) == BUILT_IN_NORMAL | 9680 && fndecl_built_in_p (orig_expr.value, BUILT_IN_CONSTANT_P)) |
9089 && DECL_FUNCTION_CODE (orig_expr.value) == BUILT_IN_CONSTANT_P) | |
9090 expr.original_code = C_MAYBE_CONST_EXPR; | 9681 expr.original_code = C_MAYBE_CONST_EXPR; |
9091 expr.original_type = NULL; | 9682 expr.original_type = NULL; |
9092 if (exprlist) | 9683 if (exprlist) |
9093 { | 9684 { |
9094 release_tree_vector (exprlist); | 9685 release_tree_vector (exprlist); |
9176 case CPP_PLUS_PLUS: | 9767 case CPP_PLUS_PLUS: |
9177 /* Postincrement. */ | 9768 /* Postincrement. */ |
9178 start = expr.get_start (); | 9769 start = expr.get_start (); |
9179 finish = c_parser_peek_token (parser)->get_finish (); | 9770 finish = c_parser_peek_token (parser)->get_finish (); |
9180 c_parser_consume_token (parser); | 9771 c_parser_consume_token (parser); |
9181 /* If the expressions have array notations, we expand them. */ | 9772 expr = default_function_array_read_conversion (expr_loc, expr); |
9182 if (flag_cilkplus | 9773 expr.value = build_unary_op (op_loc, POSTINCREMENT_EXPR, |
9183 && TREE_CODE (expr.value) == ARRAY_NOTATION_REF) | 9774 expr.value, false); |
9184 expr = fix_array_notation_expr (expr_loc, POSTINCREMENT_EXPR, expr); | |
9185 else | |
9186 { | |
9187 expr = default_function_array_read_conversion (expr_loc, expr); | |
9188 expr.value = build_unary_op (op_loc, POSTINCREMENT_EXPR, | |
9189 expr.value, false); | |
9190 } | |
9191 set_c_expr_source_range (&expr, start, finish); | 9775 set_c_expr_source_range (&expr, start, finish); |
9192 expr.original_code = ERROR_MARK; | 9776 expr.original_code = ERROR_MARK; |
9193 expr.original_type = NULL; | 9777 expr.original_type = NULL; |
9194 break; | 9778 break; |
9195 case CPP_MINUS_MINUS: | 9779 case CPP_MINUS_MINUS: |
9196 /* Postdecrement. */ | 9780 /* Postdecrement. */ |
9197 start = expr.get_start (); | 9781 start = expr.get_start (); |
9198 finish = c_parser_peek_token (parser)->get_finish (); | 9782 finish = c_parser_peek_token (parser)->get_finish (); |
9199 c_parser_consume_token (parser); | 9783 c_parser_consume_token (parser); |
9200 /* If the expressions have array notations, we expand them. */ | 9784 expr = default_function_array_read_conversion (expr_loc, expr); |
9201 if (flag_cilkplus | 9785 expr.value = build_unary_op (op_loc, POSTDECREMENT_EXPR, |
9202 && TREE_CODE (expr.value) == ARRAY_NOTATION_REF) | 9786 expr.value, false); |
9203 expr = fix_array_notation_expr (expr_loc, POSTDECREMENT_EXPR, expr); | |
9204 else | |
9205 { | |
9206 expr = default_function_array_read_conversion (expr_loc, expr); | |
9207 expr.value = build_unary_op (op_loc, POSTDECREMENT_EXPR, | |
9208 expr.value, false); | |
9209 } | |
9210 set_c_expr_source_range (&expr, start, finish); | 9787 set_c_expr_source_range (&expr, start, finish); |
9211 expr.original_code = ERROR_MARK; | 9788 expr.original_code = ERROR_MARK; |
9212 expr.original_type = NULL; | 9789 expr.original_type = NULL; |
9213 break; | 9790 break; |
9214 default: | 9791 default: |
10796 c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); | 11373 c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); |
10797 objc_add_dynamic_declaration (loc, list); | 11374 objc_add_dynamic_declaration (loc, list); |
10798 } | 11375 } |
10799 | 11376 |
10800 | 11377 |
11378 /* Parse a pragma GCC ivdep. */ | |
11379 | |
11380 static bool | |
11381 c_parse_pragma_ivdep (c_parser *parser) | |
11382 { | |
11383 c_parser_consume_pragma (parser); | |
11384 c_parser_skip_to_pragma_eol (parser); | |
11385 return true; | |
11386 } | |
11387 | |
11388 /* Parse a pragma GCC unroll. */ | |
11389 | |
11390 static unsigned short | |
11391 c_parser_pragma_unroll (c_parser *parser) | |
11392 { | |
11393 unsigned short unroll; | |
11394 c_parser_consume_pragma (parser); | |
11395 location_t location = c_parser_peek_token (parser)->location; | |
11396 tree expr = c_parser_expr_no_commas (parser, NULL).value; | |
11397 mark_exp_read (expr); | |
11398 expr = c_fully_fold (expr, false, NULL); | |
11399 HOST_WIDE_INT lunroll = 0; | |
11400 if (!INTEGRAL_TYPE_P (TREE_TYPE (expr)) | |
11401 || TREE_CODE (expr) != INTEGER_CST | |
11402 || (lunroll = tree_to_shwi (expr)) < 0 | |
11403 || lunroll >= USHRT_MAX) | |
11404 { | |
11405 error_at (location, "%<#pragma GCC unroll%> requires an" | |
11406 " assignment-expression that evaluates to a non-negative" | |
11407 " integral constant less than %u", USHRT_MAX); | |
11408 unroll = 0; | |
11409 } | |
11410 else | |
11411 { | |
11412 unroll = (unsigned short)lunroll; | |
11413 if (unroll == 0) | |
11414 unroll = 1; | |
11415 } | |
11416 | |
11417 c_parser_skip_to_pragma_eol (parser); | |
11418 return unroll; | |
11419 } | |
11420 | |
10801 /* Handle pragmas. Some OpenMP pragmas are associated with, and therefore | 11421 /* Handle pragmas. Some OpenMP pragmas are associated with, and therefore |
10802 should be considered, statements. ALLOW_STMT is true if we're within | 11422 should be considered, statements. ALLOW_STMT is true if we're within |
10803 the context of a function and such pragmas are to be allowed. Returns | 11423 the context of a function and such pragmas are to be allowed. Returns |
10804 true if we actually parsed such a pragma. */ | 11424 true if we actually parsed such a pragma. */ |
10805 | 11425 |
10938 | 11558 |
10939 case PRAGMA_OMP_ORDERED: | 11559 case PRAGMA_OMP_ORDERED: |
10940 return c_parser_omp_ordered (parser, context, if_p); | 11560 return c_parser_omp_ordered (parser, context, if_p); |
10941 | 11561 |
10942 case PRAGMA_IVDEP: | 11562 case PRAGMA_IVDEP: |
10943 c_parser_consume_pragma (parser); | 11563 { |
10944 c_parser_skip_to_pragma_eol (parser); | 11564 const bool ivdep = c_parse_pragma_ivdep (parser); |
10945 if (!c_parser_next_token_is_keyword (parser, RID_FOR) | 11565 unsigned short unroll; |
10946 && !c_parser_next_token_is_keyword (parser, RID_WHILE) | 11566 if (c_parser_peek_token (parser)->pragma_kind == PRAGMA_UNROLL) |
10947 && !c_parser_next_token_is_keyword (parser, RID_DO)) | 11567 unroll = c_parser_pragma_unroll (parser); |
10948 { | 11568 else |
10949 c_parser_error (parser, "for, while or do statement expected"); | 11569 unroll = 0; |
10950 return false; | 11570 if (!c_parser_next_token_is_keyword (parser, RID_FOR) |
10951 } | 11571 && !c_parser_next_token_is_keyword (parser, RID_WHILE) |
10952 if (c_parser_next_token_is_keyword (parser, RID_FOR)) | 11572 && !c_parser_next_token_is_keyword (parser, RID_DO)) |
10953 c_parser_for_statement (parser, true, if_p); | 11573 { |
10954 else if (c_parser_next_token_is_keyword (parser, RID_WHILE)) | 11574 c_parser_error (parser, "for, while or do statement expected"); |
10955 c_parser_while_statement (parser, true, if_p); | 11575 return false; |
10956 else | 11576 } |
10957 c_parser_do_statement (parser, true); | 11577 if (c_parser_next_token_is_keyword (parser, RID_FOR)) |
11578 c_parser_for_statement (parser, ivdep, unroll, if_p); | |
11579 else if (c_parser_next_token_is_keyword (parser, RID_WHILE)) | |
11580 c_parser_while_statement (parser, ivdep, unroll, if_p); | |
11581 else | |
11582 c_parser_do_statement (parser, ivdep, unroll); | |
11583 } | |
11584 return false; | |
11585 | |
11586 case PRAGMA_UNROLL: | |
11587 { | |
11588 unsigned short unroll = c_parser_pragma_unroll (parser); | |
11589 bool ivdep; | |
11590 if (c_parser_peek_token (parser)->pragma_kind == PRAGMA_IVDEP) | |
11591 ivdep = c_parse_pragma_ivdep (parser); | |
11592 else | |
11593 ivdep = false; | |
11594 if (!c_parser_next_token_is_keyword (parser, RID_FOR) | |
11595 && !c_parser_next_token_is_keyword (parser, RID_WHILE) | |
11596 && !c_parser_next_token_is_keyword (parser, RID_DO)) | |
11597 { | |
11598 c_parser_error (parser, "for, while or do statement expected"); | |
11599 return false; | |
11600 } | |
11601 if (c_parser_next_token_is_keyword (parser, RID_FOR)) | |
11602 c_parser_for_statement (parser, ivdep, unroll, if_p); | |
11603 else if (c_parser_next_token_is_keyword (parser, RID_WHILE)) | |
11604 c_parser_while_statement (parser, ivdep, unroll, if_p); | |
11605 else | |
11606 c_parser_do_statement (parser, ivdep, unroll); | |
11607 } | |
10958 return false; | 11608 return false; |
10959 | 11609 |
10960 case PRAGMA_GCC_PCH_PREPROCESS: | 11610 case PRAGMA_GCC_PCH_PREPROCESS: |
10961 c_parser_error (parser, "%<#pragma GCC pch_preprocess%> must be first"); | 11611 c_parser_error (parser, "%<#pragma GCC pch_preprocess%> must be first"); |
10962 c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); | 11612 c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); |
10963 return false; | |
10964 | |
10965 case PRAGMA_CILK_SIMD: | |
10966 if (!c_parser_cilk_verify_simd (parser, context)) | |
10967 return false; | |
10968 c_parser_consume_pragma (parser); | |
10969 c_parser_cilk_simd (parser, if_p); | |
10970 return false; | |
10971 case PRAGMA_CILK_GRAINSIZE: | |
10972 if (!flag_cilkplus) | |
10973 { | |
10974 warning (0, "%<#pragma grainsize%> ignored because -fcilkplus is not" | |
10975 " enabled"); | |
10976 c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); | |
10977 return false; | |
10978 } | |
10979 if (context == pragma_external) | |
10980 { | |
10981 error_at (c_parser_peek_token (parser)->location, | |
10982 "%<#pragma grainsize%> must be inside a function"); | |
10983 c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); | |
10984 return false; | |
10985 } | |
10986 c_parser_cilk_grainsize (parser, if_p); | |
10987 return false; | 11613 return false; |
10988 | 11614 |
10989 case PRAGMA_OACC_WAIT: | 11615 case PRAGMA_OACC_WAIT: |
10990 if (context != pragma_compound) | 11616 if (context != pragma_compound) |
10991 { | 11617 { |
11128 result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE; | 11754 result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE; |
11129 break; | 11755 break; |
11130 case 'f': | 11756 case 'f': |
11131 if (!strcmp ("final", p)) | 11757 if (!strcmp ("final", p)) |
11132 result = PRAGMA_OMP_CLAUSE_FINAL; | 11758 result = PRAGMA_OMP_CLAUSE_FINAL; |
11759 else if (!strcmp ("finalize", p)) | |
11760 result = PRAGMA_OACC_CLAUSE_FINALIZE; | |
11133 else if (!strcmp ("firstprivate", p)) | 11761 else if (!strcmp ("firstprivate", p)) |
11134 result = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE; | 11762 result = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE; |
11135 else if (!strcmp ("from", p)) | 11763 else if (!strcmp ("from", p)) |
11136 result = PRAGMA_OMP_CLAUSE_FROM; | 11764 result = PRAGMA_OMP_CLAUSE_FROM; |
11137 break; | 11765 break; |
11146 result = PRAGMA_OMP_CLAUSE_HINT; | 11774 result = PRAGMA_OMP_CLAUSE_HINT; |
11147 else if (!strcmp ("host", p)) | 11775 else if (!strcmp ("host", p)) |
11148 result = PRAGMA_OACC_CLAUSE_HOST; | 11776 result = PRAGMA_OACC_CLAUSE_HOST; |
11149 break; | 11777 break; |
11150 case 'i': | 11778 case 'i': |
11151 if (!strcmp ("inbranch", p)) | 11779 if (!strcmp ("if_present", p)) |
11780 result = PRAGMA_OACC_CLAUSE_IF_PRESENT; | |
11781 else if (!strcmp ("inbranch", p)) | |
11152 result = PRAGMA_OMP_CLAUSE_INBRANCH; | 11782 result = PRAGMA_OMP_CLAUSE_INBRANCH; |
11153 else if (!strcmp ("independent", p)) | 11783 else if (!strcmp ("independent", p)) |
11154 result = PRAGMA_OACC_CLAUSE_INDEPENDENT; | 11784 result = PRAGMA_OACC_CLAUSE_INDEPENDENT; |
11155 else if (!strcmp ("is_device_ptr", p)) | 11785 else if (!strcmp ("is_device_ptr", p)) |
11156 result = PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR; | 11786 result = PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR; |
11166 case 'm': | 11796 case 'm': |
11167 if (!strcmp ("map", p)) | 11797 if (!strcmp ("map", p)) |
11168 result = PRAGMA_OMP_CLAUSE_MAP; | 11798 result = PRAGMA_OMP_CLAUSE_MAP; |
11169 else if (!strcmp ("mergeable", p)) | 11799 else if (!strcmp ("mergeable", p)) |
11170 result = PRAGMA_OMP_CLAUSE_MERGEABLE; | 11800 result = PRAGMA_OMP_CLAUSE_MERGEABLE; |
11171 else if (flag_cilkplus && !strcmp ("mask", p)) | |
11172 result = PRAGMA_CILK_CLAUSE_MASK; | |
11173 break; | 11801 break; |
11174 case 'n': | 11802 case 'n': |
11175 if (!strcmp ("nogroup", p)) | 11803 if (!strcmp ("nogroup", p)) |
11176 result = PRAGMA_OMP_CLAUSE_NOGROUP; | 11804 result = PRAGMA_OMP_CLAUSE_NOGROUP; |
11177 else if (!strcmp ("notinbranch", p)) | 11805 else if (!strcmp ("notinbranch", p)) |
11186 result = PRAGMA_OMP_CLAUSE_NUM_TEAMS; | 11814 result = PRAGMA_OMP_CLAUSE_NUM_TEAMS; |
11187 else if (!strcmp ("num_threads", p)) | 11815 else if (!strcmp ("num_threads", p)) |
11188 result = PRAGMA_OMP_CLAUSE_NUM_THREADS; | 11816 result = PRAGMA_OMP_CLAUSE_NUM_THREADS; |
11189 else if (!strcmp ("num_workers", p)) | 11817 else if (!strcmp ("num_workers", p)) |
11190 result = PRAGMA_OACC_CLAUSE_NUM_WORKERS; | 11818 result = PRAGMA_OACC_CLAUSE_NUM_WORKERS; |
11191 else if (flag_cilkplus && !strcmp ("nomask", p)) | |
11192 result = PRAGMA_CILK_CLAUSE_NOMASK; | |
11193 break; | 11819 break; |
11194 case 'o': | 11820 case 'o': |
11195 if (!strcmp ("ordered", p)) | 11821 if (!strcmp ("ordered", p)) |
11196 result = PRAGMA_OMP_CLAUSE_ORDERED; | 11822 result = PRAGMA_OMP_CLAUSE_ORDERED; |
11197 break; | 11823 break; |
11198 case 'p': | 11824 case 'p': |
11199 if (!strcmp ("parallel", p)) | 11825 if (!strcmp ("parallel", p)) |
11200 result = PRAGMA_OMP_CLAUSE_PARALLEL; | 11826 result = PRAGMA_OMP_CLAUSE_PARALLEL; |
11201 else if (!strcmp ("present", p)) | 11827 else if (!strcmp ("present", p)) |
11202 result = PRAGMA_OACC_CLAUSE_PRESENT; | 11828 result = PRAGMA_OACC_CLAUSE_PRESENT; |
11829 /* As of OpenACC 2.5, these are now aliases of the non-present_or | |
11830 clauses. */ | |
11203 else if (!strcmp ("present_or_copy", p) | 11831 else if (!strcmp ("present_or_copy", p) |
11204 || !strcmp ("pcopy", p)) | 11832 || !strcmp ("pcopy", p)) |
11205 result = PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY; | 11833 result = PRAGMA_OACC_CLAUSE_COPY; |
11206 else if (!strcmp ("present_or_copyin", p) | 11834 else if (!strcmp ("present_or_copyin", p) |
11207 || !strcmp ("pcopyin", p)) | 11835 || !strcmp ("pcopyin", p)) |
11208 result = PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN; | 11836 result = PRAGMA_OACC_CLAUSE_COPYIN; |
11209 else if (!strcmp ("present_or_copyout", p) | 11837 else if (!strcmp ("present_or_copyout", p) |
11210 || !strcmp ("pcopyout", p)) | 11838 || !strcmp ("pcopyout", p)) |
11211 result = PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT; | 11839 result = PRAGMA_OACC_CLAUSE_COPYOUT; |
11212 else if (!strcmp ("present_or_create", p) | 11840 else if (!strcmp ("present_or_create", p) |
11213 || !strcmp ("pcreate", p)) | 11841 || !strcmp ("pcreate", p)) |
11214 result = PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE; | 11842 result = PRAGMA_OACC_CLAUSE_CREATE; |
11215 else if (!strcmp ("priority", p)) | 11843 else if (!strcmp ("priority", p)) |
11216 result = PRAGMA_OMP_CLAUSE_PRIORITY; | 11844 result = PRAGMA_OMP_CLAUSE_PRIORITY; |
11217 else if (!strcmp ("private", p)) | 11845 else if (!strcmp ("private", p)) |
11218 result = PRAGMA_OMP_CLAUSE_PRIVATE; | 11846 result = PRAGMA_OMP_CLAUSE_PRIVATE; |
11219 else if (!strcmp ("proc_bind", p)) | 11847 else if (!strcmp ("proc_bind", p)) |
11228 result = PRAGMA_OMP_CLAUSE_SAFELEN; | 11856 result = PRAGMA_OMP_CLAUSE_SAFELEN; |
11229 else if (!strcmp ("schedule", p)) | 11857 else if (!strcmp ("schedule", p)) |
11230 result = PRAGMA_OMP_CLAUSE_SCHEDULE; | 11858 result = PRAGMA_OMP_CLAUSE_SCHEDULE; |
11231 else if (!strcmp ("sections", p)) | 11859 else if (!strcmp ("sections", p)) |
11232 result = PRAGMA_OMP_CLAUSE_SECTIONS; | 11860 result = PRAGMA_OMP_CLAUSE_SECTIONS; |
11861 else if (!strcmp ("self", p)) /* "self" is a synonym for "host". */ | |
11862 result = PRAGMA_OACC_CLAUSE_HOST; | |
11233 else if (!strcmp ("seq", p)) | 11863 else if (!strcmp ("seq", p)) |
11234 result = PRAGMA_OACC_CLAUSE_SEQ; | 11864 result = PRAGMA_OACC_CLAUSE_SEQ; |
11235 else if (!strcmp ("shared", p)) | 11865 else if (!strcmp ("shared", p)) |
11236 result = PRAGMA_OMP_CLAUSE_SHARED; | 11866 result = PRAGMA_OMP_CLAUSE_SHARED; |
11237 else if (!strcmp ("simd", p)) | 11867 else if (!strcmp ("simd", p)) |
11238 result = PRAGMA_OMP_CLAUSE_SIMD; | 11868 result = PRAGMA_OMP_CLAUSE_SIMD; |
11239 else if (!strcmp ("simdlen", p)) | 11869 else if (!strcmp ("simdlen", p)) |
11240 result = PRAGMA_OMP_CLAUSE_SIMDLEN; | 11870 result = PRAGMA_OMP_CLAUSE_SIMDLEN; |
11241 else if (!strcmp ("self", p)) | |
11242 result = PRAGMA_OACC_CLAUSE_SELF; | |
11243 break; | 11871 break; |
11244 case 't': | 11872 case 't': |
11245 if (!strcmp ("taskgroup", p)) | 11873 if (!strcmp ("taskgroup", p)) |
11246 result = PRAGMA_OMP_CLAUSE_TASKGROUP; | 11874 result = PRAGMA_OMP_CLAUSE_TASKGROUP; |
11247 else if (!strcmp ("thread_limit", p)) | 11875 else if (!strcmp ("thread_limit", p)) |
11266 case 'v': | 11894 case 'v': |
11267 if (!strcmp ("vector", p)) | 11895 if (!strcmp ("vector", p)) |
11268 result = PRAGMA_OACC_CLAUSE_VECTOR; | 11896 result = PRAGMA_OACC_CLAUSE_VECTOR; |
11269 else if (!strcmp ("vector_length", p)) | 11897 else if (!strcmp ("vector_length", p)) |
11270 result = PRAGMA_OACC_CLAUSE_VECTOR_LENGTH; | 11898 result = PRAGMA_OACC_CLAUSE_VECTOR_LENGTH; |
11271 else if (flag_cilkplus && !strcmp ("vectorlength", p)) | |
11272 result = PRAGMA_CILK_CLAUSE_VECTORLENGTH; | |
11273 break; | 11899 break; |
11274 case 'w': | 11900 case 'w': |
11275 if (!strcmp ("wait", p)) | 11901 if (!strcmp ("wait", p)) |
11276 result = PRAGMA_OACC_CLAUSE_WAIT; | 11902 result = PRAGMA_OACC_CLAUSE_WAIT; |
11277 else if (!strcmp ("worker", p)) | 11903 else if (!strcmp ("worker", p)) |
11521 copy ( variable-list ) | 12147 copy ( variable-list ) |
11522 copyin ( variable-list ) | 12148 copyin ( variable-list ) |
11523 copyout ( variable-list ) | 12149 copyout ( variable-list ) |
11524 create ( variable-list ) | 12150 create ( variable-list ) |
11525 delete ( variable-list ) | 12151 delete ( variable-list ) |
11526 present ( variable-list ) | 12152 present ( variable-list ) */ |
11527 present_or_copy ( variable-list ) | |
11528 pcopy ( variable-list ) | |
11529 present_or_copyin ( variable-list ) | |
11530 pcopyin ( variable-list ) | |
11531 present_or_copyout ( variable-list ) | |
11532 pcopyout ( variable-list ) | |
11533 present_or_create ( variable-list ) | |
11534 pcreate ( variable-list ) */ | |
11535 | 12153 |
11536 static tree | 12154 static tree |
11537 c_parser_oacc_data_clause (c_parser *parser, pragma_omp_clause c_kind, | 12155 c_parser_oacc_data_clause (c_parser *parser, pragma_omp_clause c_kind, |
11538 tree list) | 12156 tree list) |
11539 { | 12157 { |
11540 enum gomp_map_kind kind; | 12158 enum gomp_map_kind kind; |
11541 switch (c_kind) | 12159 switch (c_kind) |
11542 { | 12160 { |
11543 case PRAGMA_OACC_CLAUSE_COPY: | 12161 case PRAGMA_OACC_CLAUSE_COPY: |
11544 kind = GOMP_MAP_FORCE_TOFROM; | 12162 kind = GOMP_MAP_TOFROM; |
11545 break; | 12163 break; |
11546 case PRAGMA_OACC_CLAUSE_COPYIN: | 12164 case PRAGMA_OACC_CLAUSE_COPYIN: |
11547 kind = GOMP_MAP_FORCE_TO; | 12165 kind = GOMP_MAP_TO; |
11548 break; | 12166 break; |
11549 case PRAGMA_OACC_CLAUSE_COPYOUT: | 12167 case PRAGMA_OACC_CLAUSE_COPYOUT: |
11550 kind = GOMP_MAP_FORCE_FROM; | 12168 kind = GOMP_MAP_FROM; |
11551 break; | 12169 break; |
11552 case PRAGMA_OACC_CLAUSE_CREATE: | 12170 case PRAGMA_OACC_CLAUSE_CREATE: |
11553 kind = GOMP_MAP_FORCE_ALLOC; | 12171 kind = GOMP_MAP_ALLOC; |
11554 break; | 12172 break; |
11555 case PRAGMA_OACC_CLAUSE_DELETE: | 12173 case PRAGMA_OACC_CLAUSE_DELETE: |
11556 kind = GOMP_MAP_DELETE; | 12174 kind = GOMP_MAP_RELEASE; |
11557 break; | 12175 break; |
11558 case PRAGMA_OACC_CLAUSE_DEVICE: | 12176 case PRAGMA_OACC_CLAUSE_DEVICE: |
11559 kind = GOMP_MAP_FORCE_TO; | 12177 kind = GOMP_MAP_FORCE_TO; |
11560 break; | 12178 break; |
11561 case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT: | 12179 case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT: |
11562 kind = GOMP_MAP_DEVICE_RESIDENT; | 12180 kind = GOMP_MAP_DEVICE_RESIDENT; |
11563 break; | 12181 break; |
11564 case PRAGMA_OACC_CLAUSE_HOST: | 12182 case PRAGMA_OACC_CLAUSE_HOST: |
11565 case PRAGMA_OACC_CLAUSE_SELF: | |
11566 kind = GOMP_MAP_FORCE_FROM; | 12183 kind = GOMP_MAP_FORCE_FROM; |
11567 break; | 12184 break; |
11568 case PRAGMA_OACC_CLAUSE_LINK: | 12185 case PRAGMA_OACC_CLAUSE_LINK: |
11569 kind = GOMP_MAP_LINK; | 12186 kind = GOMP_MAP_LINK; |
11570 break; | 12187 break; |
11571 case PRAGMA_OACC_CLAUSE_PRESENT: | 12188 case PRAGMA_OACC_CLAUSE_PRESENT: |
11572 kind = GOMP_MAP_FORCE_PRESENT; | 12189 kind = GOMP_MAP_FORCE_PRESENT; |
11573 break; | |
11574 case PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY: | |
11575 kind = GOMP_MAP_TOFROM; | |
11576 break; | |
11577 case PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN: | |
11578 kind = GOMP_MAP_TO; | |
11579 break; | |
11580 case PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT: | |
11581 kind = GOMP_MAP_FROM; | |
11582 break; | |
11583 case PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE: | |
11584 kind = GOMP_MAP_ALLOC; | |
11585 break; | 12190 break; |
11586 default: | 12191 default: |
11587 gcc_unreachable (); | 12192 gcc_unreachable (); |
11588 } | 12193 } |
11589 tree nl, c; | 12194 tree nl, c; |
12472 cleanup_error: | 13077 cleanup_error: |
12473 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0); | 13078 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0); |
12474 return list; | 13079 return list; |
12475 } | 13080 } |
12476 | 13081 |
12477 /* OpenACC: | 13082 /* OpenACC 2.5: |
12478 auto | 13083 auto |
13084 finalize | |
12479 independent | 13085 independent |
12480 nohost | 13086 nohost |
12481 seq */ | 13087 seq */ |
12482 | 13088 |
12483 static tree | 13089 static tree |
13168 OpenMP 4.5: | 13774 OpenMP 4.5: |
13169 linear ( modifier ( variable-list ) ) | 13775 linear ( modifier ( variable-list ) ) |
13170 linear ( modifier ( variable-list ) : expression ) */ | 13776 linear ( modifier ( variable-list ) : expression ) */ |
13171 | 13777 |
13172 static tree | 13778 static tree |
13173 c_parser_omp_clause_linear (c_parser *parser, tree list, bool is_cilk_simd_fn) | 13779 c_parser_omp_clause_linear (c_parser *parser, tree list) |
13174 { | 13780 { |
13175 location_t clause_loc = c_parser_peek_token (parser)->location; | 13781 location_t clause_loc = c_parser_peek_token (parser)->location; |
13176 tree nl, c, step; | 13782 tree nl, c, step; |
13177 enum omp_clause_linear_kind kind = OMP_CLAUSE_LINEAR_DEFAULT; | 13783 enum omp_clause_linear_kind kind = OMP_CLAUSE_LINEAR_DEFAULT; |
13178 | 13784 |
13179 matching_parens parens; | 13785 matching_parens parens; |
13180 if (!parens.require_open (parser)) | 13786 if (!parens.require_open (parser)) |
13181 return list; | 13787 return list; |
13182 | 13788 |
13183 if (!is_cilk_simd_fn | 13789 if (c_parser_next_token_is (parser, CPP_NAME)) |
13184 && c_parser_next_token_is (parser, CPP_NAME)) | |
13185 { | 13790 { |
13186 c_token *tok = c_parser_peek_token (parser); | 13791 c_token *tok = c_parser_peek_token (parser); |
13187 const char *p = IDENTIFIER_POINTER (tok->value); | 13792 const char *p = IDENTIFIER_POINTER (tok->value); |
13188 if (strcmp ("val", p) == 0) | 13793 if (strcmp ("val", p) == 0) |
13189 kind = OMP_CLAUSE_LINEAR_VAL; | 13794 kind = OMP_CLAUSE_LINEAR_VAL; |
13208 location_t expr_loc = c_parser_peek_token (parser)->location; | 13813 location_t expr_loc = c_parser_peek_token (parser)->location; |
13209 c_expr expr = c_parser_expression (parser); | 13814 c_expr expr = c_parser_expression (parser); |
13210 expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); | 13815 expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); |
13211 step = expr.value; | 13816 step = expr.value; |
13212 step = c_fully_fold (step, false, NULL); | 13817 step = c_fully_fold (step, false, NULL); |
13213 if (is_cilk_simd_fn && TREE_CODE (step) == PARM_DECL) | |
13214 { | |
13215 sorry ("using parameters for %<linear%> step is not supported yet"); | |
13216 step = integer_one_node; | |
13217 } | |
13218 if (!INTEGRAL_TYPE_P (TREE_TYPE (step))) | 13818 if (!INTEGRAL_TYPE_P (TREE_TYPE (step))) |
13219 { | 13819 { |
13220 error_at (clause_loc, "%<linear%> clause step expression must " | 13820 error_at (clause_loc, "%<linear%> clause step expression must " |
13221 "be integral"); | 13821 "be integral"); |
13222 step = integer_one_node; | 13822 step = integer_one_node; |
13836 break; | 14436 break; |
13837 case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT: | 14437 case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT: |
13838 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | 14438 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); |
13839 c_name = "device_resident"; | 14439 c_name = "device_resident"; |
13840 break; | 14440 break; |
14441 case PRAGMA_OACC_CLAUSE_FINALIZE: | |
14442 clauses = c_parser_oacc_simple_clause (parser, OMP_CLAUSE_FINALIZE, | |
14443 clauses); | |
14444 c_name = "finalize"; | |
14445 break; | |
13841 case PRAGMA_OACC_CLAUSE_FIRSTPRIVATE: | 14446 case PRAGMA_OACC_CLAUSE_FIRSTPRIVATE: |
13842 clauses = c_parser_omp_clause_firstprivate (parser, clauses); | 14447 clauses = c_parser_omp_clause_firstprivate (parser, clauses); |
13843 c_name = "firstprivate"; | 14448 c_name = "firstprivate"; |
13844 break; | 14449 break; |
13845 case PRAGMA_OACC_CLAUSE_GANG: | 14450 case PRAGMA_OACC_CLAUSE_GANG: |
13852 c_name = "host"; | 14457 c_name = "host"; |
13853 break; | 14458 break; |
13854 case PRAGMA_OACC_CLAUSE_IF: | 14459 case PRAGMA_OACC_CLAUSE_IF: |
13855 clauses = c_parser_omp_clause_if (parser, clauses, false); | 14460 clauses = c_parser_omp_clause_if (parser, clauses, false); |
13856 c_name = "if"; | 14461 c_name = "if"; |
14462 break; | |
14463 case PRAGMA_OACC_CLAUSE_IF_PRESENT: | |
14464 clauses = c_parser_oacc_simple_clause (parser, OMP_CLAUSE_IF_PRESENT, | |
14465 clauses); | |
14466 c_name = "if_present"; | |
13857 break; | 14467 break; |
13858 case PRAGMA_OACC_CLAUSE_INDEPENDENT: | 14468 case PRAGMA_OACC_CLAUSE_INDEPENDENT: |
13859 clauses = c_parser_oacc_simple_clause (parser, OMP_CLAUSE_INDEPENDENT, | 14469 clauses = c_parser_oacc_simple_clause (parser, OMP_CLAUSE_INDEPENDENT, |
13860 clauses); | 14470 clauses); |
13861 c_name = "independent"; | 14471 c_name = "independent"; |
13878 break; | 14488 break; |
13879 case PRAGMA_OACC_CLAUSE_PRESENT: | 14489 case PRAGMA_OACC_CLAUSE_PRESENT: |
13880 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | 14490 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); |
13881 c_name = "present"; | 14491 c_name = "present"; |
13882 break; | 14492 break; |
13883 case PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY: | |
13884 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | |
13885 c_name = "present_or_copy"; | |
13886 break; | |
13887 case PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN: | |
13888 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | |
13889 c_name = "present_or_copyin"; | |
13890 break; | |
13891 case PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT: | |
13892 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | |
13893 c_name = "present_or_copyout"; | |
13894 break; | |
13895 case PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE: | |
13896 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | |
13897 c_name = "present_or_create"; | |
13898 break; | |
13899 case PRAGMA_OACC_CLAUSE_PRIVATE: | 14493 case PRAGMA_OACC_CLAUSE_PRIVATE: |
13900 clauses = c_parser_omp_clause_private (parser, clauses); | 14494 clauses = c_parser_omp_clause_private (parser, clauses); |
13901 c_name = "private"; | 14495 c_name = "private"; |
13902 break; | 14496 break; |
13903 case PRAGMA_OACC_CLAUSE_REDUCTION: | 14497 case PRAGMA_OACC_CLAUSE_REDUCTION: |
13904 clauses = c_parser_omp_clause_reduction (parser, clauses); | 14498 clauses = c_parser_omp_clause_reduction (parser, clauses); |
13905 c_name = "reduction"; | 14499 c_name = "reduction"; |
13906 break; | |
13907 case PRAGMA_OACC_CLAUSE_SELF: | |
13908 clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); | |
13909 c_name = "self"; | |
13910 break; | 14500 break; |
13911 case PRAGMA_OACC_CLAUSE_SEQ: | 14501 case PRAGMA_OACC_CLAUSE_SEQ: |
13912 clauses = c_parser_oacc_simple_clause (parser, OMP_CLAUSE_SEQ, | 14502 clauses = c_parser_oacc_simple_clause (parser, OMP_CLAUSE_SEQ, |
13913 clauses); | 14503 clauses); |
13914 c_name = "seq"; | 14504 c_name = "seq"; |
13972 static tree | 14562 static tree |
13973 c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, | 14563 c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, |
13974 const char *where, bool finish_p = true) | 14564 const char *where, bool finish_p = true) |
13975 { | 14565 { |
13976 tree clauses = NULL; | 14566 tree clauses = NULL; |
13977 bool first = true, cilk_simd_fn = false; | 14567 bool first = true; |
13978 | 14568 |
13979 while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) | 14569 while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) |
13980 { | 14570 { |
13981 location_t here; | 14571 location_t here; |
13982 pragma_omp_clause c_kind; | 14572 pragma_omp_clause c_kind; |
14078 case PRAGMA_OMP_CLAUSE_UNTIED: | 14668 case PRAGMA_OMP_CLAUSE_UNTIED: |
14079 clauses = c_parser_omp_clause_untied (parser, clauses); | 14669 clauses = c_parser_omp_clause_untied (parser, clauses); |
14080 c_name = "untied"; | 14670 c_name = "untied"; |
14081 break; | 14671 break; |
14082 case PRAGMA_OMP_CLAUSE_INBRANCH: | 14672 case PRAGMA_OMP_CLAUSE_INBRANCH: |
14083 case PRAGMA_CILK_CLAUSE_MASK: | |
14084 clauses = c_parser_omp_clause_branch (parser, OMP_CLAUSE_INBRANCH, | 14673 clauses = c_parser_omp_clause_branch (parser, OMP_CLAUSE_INBRANCH, |
14085 clauses); | 14674 clauses); |
14086 c_name = "inbranch"; | 14675 c_name = "inbranch"; |
14087 break; | 14676 break; |
14088 case PRAGMA_OMP_CLAUSE_NOTINBRANCH: | 14677 case PRAGMA_OMP_CLAUSE_NOTINBRANCH: |
14089 case PRAGMA_CILK_CLAUSE_NOMASK: | |
14090 clauses = c_parser_omp_clause_branch (parser, OMP_CLAUSE_NOTINBRANCH, | 14678 clauses = c_parser_omp_clause_branch (parser, OMP_CLAUSE_NOTINBRANCH, |
14091 clauses); | 14679 clauses); |
14092 c_name = "notinbranch"; | 14680 c_name = "notinbranch"; |
14093 break; | 14681 break; |
14094 case PRAGMA_OMP_CLAUSE_PARALLEL: | 14682 case PRAGMA_OMP_CLAUSE_PARALLEL: |
14161 case PRAGMA_OMP_CLAUSE_ALIGNED: | 14749 case PRAGMA_OMP_CLAUSE_ALIGNED: |
14162 clauses = c_parser_omp_clause_aligned (parser, clauses); | 14750 clauses = c_parser_omp_clause_aligned (parser, clauses); |
14163 c_name = "aligned"; | 14751 c_name = "aligned"; |
14164 break; | 14752 break; |
14165 case PRAGMA_OMP_CLAUSE_LINEAR: | 14753 case PRAGMA_OMP_CLAUSE_LINEAR: |
14166 if (((mask >> PRAGMA_CILK_CLAUSE_VECTORLENGTH) & 1) != 0) | 14754 clauses = c_parser_omp_clause_linear (parser, clauses); |
14167 cilk_simd_fn = true; | |
14168 clauses = c_parser_omp_clause_linear (parser, clauses, cilk_simd_fn); | |
14169 c_name = "linear"; | 14755 c_name = "linear"; |
14170 break; | 14756 break; |
14171 case PRAGMA_OMP_CLAUSE_DEPEND: | 14757 case PRAGMA_OMP_CLAUSE_DEPEND: |
14172 clauses = c_parser_omp_clause_depend (parser, clauses); | 14758 clauses = c_parser_omp_clause_depend (parser, clauses); |
14173 c_name = "depend"; | 14759 c_name = "depend"; |
14197 c_name = "proc_bind"; | 14783 c_name = "proc_bind"; |
14198 break; | 14784 break; |
14199 case PRAGMA_OMP_CLAUSE_SAFELEN: | 14785 case PRAGMA_OMP_CLAUSE_SAFELEN: |
14200 clauses = c_parser_omp_clause_safelen (parser, clauses); | 14786 clauses = c_parser_omp_clause_safelen (parser, clauses); |
14201 c_name = "safelen"; | 14787 c_name = "safelen"; |
14202 break; | |
14203 case PRAGMA_CILK_CLAUSE_VECTORLENGTH: | |
14204 clauses = c_parser_cilk_clause_vectorlength (parser, clauses, true); | |
14205 c_name = "simdlen"; | |
14206 break; | 14788 break; |
14207 case PRAGMA_OMP_CLAUSE_SIMDLEN: | 14789 case PRAGMA_OMP_CLAUSE_SIMDLEN: |
14208 clauses = c_parser_omp_clause_simdlen (parser, clauses); | 14790 clauses = c_parser_omp_clause_simdlen (parser, clauses); |
14209 c_name = "simdlen"; | 14791 c_name = "simdlen"; |
14210 break; | 14792 break; |
14306 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN) \ | 14888 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN) \ |
14307 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \ | 14889 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \ |
14308 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \ | 14890 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \ |
14309 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \ | 14891 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \ |
14310 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ | 14892 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ |
14311 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \ | 14893 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT)) |
14312 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY) \ | |
14313 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \ | |
14314 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT) \ | |
14315 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) ) | |
14316 | 14894 |
14317 static tree | 14895 static tree |
14318 c_parser_oacc_data (location_t loc, c_parser *parser, bool *if_p) | 14896 c_parser_oacc_data (location_t loc, c_parser *parser, bool *if_p) |
14319 { | 14897 { |
14320 tree stmt, clauses, block; | 14898 tree stmt, clauses, block; |
14340 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \ | 14918 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \ |
14341 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \ | 14919 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \ |
14342 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \ | 14920 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \ |
14343 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT) \ | 14921 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT) \ |
14344 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_LINK) \ | 14922 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_LINK) \ |
14345 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \ | 14923 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT)) |
14346 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY) \ | |
14347 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \ | |
14348 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT) \ | |
14349 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) ) | |
14350 | 14924 |
14351 static void | 14925 static void |
14352 c_parser_oacc_declare (c_parser *parser) | 14926 c_parser_oacc_declare (c_parser *parser) |
14353 { | 14927 { |
14354 location_t pragma_loc = c_parser_peek_token (parser)->location; | 14928 location_t pragma_loc = c_parser_peek_token (parser)->location; |
14379 } | 14953 } |
14380 | 14954 |
14381 switch (OMP_CLAUSE_MAP_KIND (t)) | 14955 switch (OMP_CLAUSE_MAP_KIND (t)) |
14382 { | 14956 { |
14383 case GOMP_MAP_FIRSTPRIVATE_POINTER: | 14957 case GOMP_MAP_FIRSTPRIVATE_POINTER: |
14384 case GOMP_MAP_FORCE_ALLOC: | 14958 case GOMP_MAP_ALLOC: |
14385 case GOMP_MAP_FORCE_TO: | 14959 case GOMP_MAP_TO: |
14386 case GOMP_MAP_FORCE_DEVICEPTR: | 14960 case GOMP_MAP_FORCE_DEVICEPTR: |
14387 case GOMP_MAP_DEVICE_RESIDENT: | 14961 case GOMP_MAP_DEVICE_RESIDENT: |
14388 break; | 14962 break; |
14389 | 14963 |
14390 case GOMP_MAP_LINK: | 14964 case GOMP_MAP_LINK: |
14493 #define OACC_ENTER_DATA_CLAUSE_MASK \ | 15067 #define OACC_ENTER_DATA_CLAUSE_MASK \ |
14494 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ | 15068 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ |
14495 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ | 15069 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ |
14496 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN) \ | 15070 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN) \ |
14497 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \ | 15071 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \ |
14498 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \ | |
14499 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) \ | |
14500 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) | 15072 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) |
14501 | 15073 |
14502 #define OACC_EXIT_DATA_CLAUSE_MASK \ | 15074 #define OACC_EXIT_DATA_CLAUSE_MASK \ |
14503 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ | 15075 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ |
14504 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ | 15076 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ |
14505 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \ | 15077 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \ |
14506 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DELETE) \ | 15078 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DELETE) \ |
15079 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_FINALIZE) \ | |
14507 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) | 15080 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) |
14508 | 15081 |
14509 static void | 15082 static void |
14510 c_parser_oacc_enter_exit_data (c_parser *parser, bool enter) | 15083 c_parser_oacc_enter_exit_data (c_parser *parser, bool enter) |
14511 { | 15084 { |
14645 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \ | 15218 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \ |
14646 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ | 15219 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ |
14647 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_GANGS) \ | 15220 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_GANGS) \ |
14648 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_WORKERS) \ | 15221 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_WORKERS) \ |
14649 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \ | 15222 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \ |
14650 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY) \ | |
14651 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \ | |
14652 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT) \ | |
14653 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) \ | |
14654 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR_LENGTH) \ | 15223 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR_LENGTH) \ |
14655 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) | 15224 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) |
14656 | 15225 |
14657 #define OACC_PARALLEL_CLAUSE_MASK \ | 15226 #define OACC_PARALLEL_CLAUSE_MASK \ |
14658 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ | 15227 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ |
14666 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRIVATE) \ | 15235 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRIVATE) \ |
14667 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_FIRSTPRIVATE) \ | 15236 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_FIRSTPRIVATE) \ |
14668 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_GANGS) \ | 15237 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_GANGS) \ |
14669 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_WORKERS) \ | 15238 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_WORKERS) \ |
14670 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \ | 15239 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \ |
14671 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY) \ | |
14672 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \ | |
14673 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT) \ | |
14674 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) \ | |
14675 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION) \ | 15240 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION) \ |
14676 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR_LENGTH) \ | 15241 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR_LENGTH) \ |
14677 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) | 15242 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) |
14678 | 15243 |
14679 static tree | 15244 static tree |
14897 #define OACC_UPDATE_CLAUSE_MASK \ | 15462 #define OACC_UPDATE_CLAUSE_MASK \ |
14898 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ | 15463 ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \ |
14899 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICE) \ | 15464 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICE) \ |
14900 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST) \ | 15465 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST) \ |
14901 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ | 15466 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ |
14902 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SELF) \ | 15467 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF_PRESENT) \ |
14903 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) | 15468 | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) |
14904 | 15469 |
14905 static void | 15470 static void |
14906 c_parser_oacc_update (c_parser *parser) | 15471 c_parser_oacc_update (c_parser *parser) |
14907 { | 15472 { |
15073 { | 15638 { |
15074 case OMP_ATOMIC_READ: | 15639 case OMP_ATOMIC_READ: |
15075 case NOP_EXPR: /* atomic write */ | 15640 case NOP_EXPR: /* atomic write */ |
15076 v = c_parser_cast_expression (parser, NULL).value; | 15641 v = c_parser_cast_expression (parser, NULL).value; |
15077 non_lvalue_p = !lvalue_p (v); | 15642 non_lvalue_p = !lvalue_p (v); |
15078 v = c_fully_fold (v, false, NULL); | 15643 v = c_fully_fold (v, false, NULL, true); |
15079 if (v == error_mark_node) | 15644 if (v == error_mark_node) |
15080 goto saw_error; | 15645 goto saw_error; |
15081 if (non_lvalue_p) | 15646 if (non_lvalue_p) |
15082 v = non_lvalue (v); | 15647 v = non_lvalue (v); |
15083 loc = c_parser_peek_token (parser)->location; | 15648 loc = c_parser_peek_token (parser)->location; |
15092 } | 15657 } |
15093 else | 15658 else |
15094 { | 15659 { |
15095 lhs = c_parser_cast_expression (parser, NULL).value; | 15660 lhs = c_parser_cast_expression (parser, NULL).value; |
15096 non_lvalue_p = !lvalue_p (lhs); | 15661 non_lvalue_p = !lvalue_p (lhs); |
15097 lhs = c_fully_fold (lhs, false, NULL); | 15662 lhs = c_fully_fold (lhs, false, NULL, true); |
15098 if (lhs == error_mark_node) | 15663 if (lhs == error_mark_node) |
15099 goto saw_error; | 15664 goto saw_error; |
15100 if (non_lvalue_p) | 15665 if (non_lvalue_p) |
15101 lhs = non_lvalue (lhs); | 15666 lhs = non_lvalue (lhs); |
15102 } | 15667 } |
15118 } | 15683 } |
15119 else | 15684 else |
15120 { | 15685 { |
15121 v = c_parser_cast_expression (parser, NULL).value; | 15686 v = c_parser_cast_expression (parser, NULL).value; |
15122 non_lvalue_p = !lvalue_p (v); | 15687 non_lvalue_p = !lvalue_p (v); |
15123 v = c_fully_fold (v, false, NULL); | 15688 v = c_fully_fold (v, false, NULL, true); |
15124 if (v == error_mark_node) | 15689 if (v == error_mark_node) |
15125 goto saw_error; | 15690 goto saw_error; |
15126 if (non_lvalue_p) | 15691 if (non_lvalue_p) |
15127 v = non_lvalue (v); | 15692 v = non_lvalue (v); |
15128 if (!c_parser_require (parser, CPP_EQ, "expected %<=%>")) | 15693 if (!c_parser_require (parser, CPP_EQ, "expected %<=%>")) |
15139 eloc = c_parser_peek_token (parser)->location; | 15704 eloc = c_parser_peek_token (parser)->location; |
15140 expr = c_parser_cast_expression (parser, NULL); | 15705 expr = c_parser_cast_expression (parser, NULL); |
15141 lhs = expr.value; | 15706 lhs = expr.value; |
15142 expr = default_function_array_conversion (eloc, expr); | 15707 expr = default_function_array_conversion (eloc, expr); |
15143 unfolded_lhs = expr.value; | 15708 unfolded_lhs = expr.value; |
15144 lhs = c_fully_fold (lhs, false, NULL); | 15709 lhs = c_fully_fold (lhs, false, NULL, true); |
15145 orig_lhs = lhs; | 15710 orig_lhs = lhs; |
15146 switch (TREE_CODE (lhs)) | 15711 switch (TREE_CODE (lhs)) |
15147 { | 15712 { |
15148 case ERROR_MARK: | 15713 case ERROR_MARK: |
15149 saw_error: | 15714 saw_error: |
15279 case BIT_IOR_EXPR: | 15844 case BIT_IOR_EXPR: |
15280 case BIT_XOR_EXPR: | 15845 case BIT_XOR_EXPR: |
15281 if (c_tree_equal (TREE_OPERAND (rhs1, 0), unfolded_lhs)) | 15846 if (c_tree_equal (TREE_OPERAND (rhs1, 0), unfolded_lhs)) |
15282 { | 15847 { |
15283 opcode = TREE_CODE (rhs1); | 15848 opcode = TREE_CODE (rhs1); |
15284 rhs = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL); | 15849 rhs = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL, |
15285 rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 0), false, NULL); | 15850 true); |
15851 rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 0), false, NULL, | |
15852 true); | |
15286 goto stmt_done; | 15853 goto stmt_done; |
15287 } | 15854 } |
15288 if (c_tree_equal (TREE_OPERAND (rhs1, 1), unfolded_lhs)) | 15855 if (c_tree_equal (TREE_OPERAND (rhs1, 1), unfolded_lhs)) |
15289 { | 15856 { |
15290 opcode = TREE_CODE (rhs1); | 15857 opcode = TREE_CODE (rhs1); |
15291 rhs = c_fully_fold (TREE_OPERAND (rhs1, 0), false, NULL); | 15858 rhs = c_fully_fold (TREE_OPERAND (rhs1, 0), false, NULL, |
15292 rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL); | 15859 true); |
15860 rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL, | |
15861 true); | |
15293 swapped = !commutative_tree_code (opcode); | 15862 swapped = !commutative_tree_code (opcode); |
15294 goto stmt_done; | 15863 goto stmt_done; |
15295 } | 15864 } |
15296 break; | 15865 break; |
15297 case ERROR_MARK: | 15866 case ERROR_MARK: |
15306 code = OMP_ATOMIC_CAPTURE_OLD; | 15875 code = OMP_ATOMIC_CAPTURE_OLD; |
15307 v = lhs; | 15876 v = lhs; |
15308 lhs = NULL_TREE; | 15877 lhs = NULL_TREE; |
15309 expr = default_function_array_read_conversion (eloc, expr); | 15878 expr = default_function_array_read_conversion (eloc, expr); |
15310 unfolded_lhs1 = expr.value; | 15879 unfolded_lhs1 = expr.value; |
15311 lhs1 = c_fully_fold (unfolded_lhs1, false, NULL); | 15880 lhs1 = c_fully_fold (unfolded_lhs1, false, NULL, true); |
15312 rhs1 = NULL_TREE; | 15881 rhs1 = NULL_TREE; |
15313 c_parser_consume_token (parser); | 15882 c_parser_consume_token (parser); |
15314 goto restart; | 15883 goto restart; |
15315 } | 15884 } |
15316 if (structured_block) | 15885 if (structured_block) |
15317 { | 15886 { |
15318 opcode = NOP_EXPR; | 15887 opcode = NOP_EXPR; |
15319 expr = default_function_array_read_conversion (eloc, expr); | 15888 expr = default_function_array_read_conversion (eloc, expr); |
15320 rhs = c_fully_fold (expr.value, false, NULL); | 15889 rhs = c_fully_fold (expr.value, false, NULL, true); |
15321 rhs1 = NULL_TREE; | 15890 rhs1 = NULL_TREE; |
15322 goto stmt_done; | 15891 goto stmt_done; |
15323 } | 15892 } |
15324 } | 15893 } |
15325 c_parser_error (parser, "invalid form of %<#pragma omp atomic%>"); | 15894 c_parser_error (parser, "invalid form of %<#pragma omp atomic%>"); |
15336 c_parser_consume_token (parser); | 15905 c_parser_consume_token (parser); |
15337 eloc = c_parser_peek_token (parser)->location; | 15906 eloc = c_parser_peek_token (parser)->location; |
15338 expr = c_parser_expression (parser); | 15907 expr = c_parser_expression (parser); |
15339 expr = default_function_array_read_conversion (eloc, expr); | 15908 expr = default_function_array_read_conversion (eloc, expr); |
15340 rhs = expr.value; | 15909 rhs = expr.value; |
15341 rhs = c_fully_fold (rhs, false, NULL); | 15910 rhs = c_fully_fold (rhs, false, NULL, true); |
15342 break; | 15911 break; |
15343 } | 15912 } |
15344 stmt_done: | 15913 stmt_done: |
15345 if (structured_block && code == OMP_ATOMIC_CAPTURE_NEW) | 15914 if (structured_block && code == OMP_ATOMIC_CAPTURE_NEW) |
15346 { | 15915 { |
15347 if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) | 15916 if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) |
15348 goto saw_error; | 15917 goto saw_error; |
15349 v = c_parser_cast_expression (parser, NULL).value; | 15918 v = c_parser_cast_expression (parser, NULL).value; |
15350 non_lvalue_p = !lvalue_p (v); | 15919 non_lvalue_p = !lvalue_p (v); |
15351 v = c_fully_fold (v, false, NULL); | 15920 v = c_fully_fold (v, false, NULL, true); |
15352 if (v == error_mark_node) | 15921 if (v == error_mark_node) |
15353 goto saw_error; | 15922 goto saw_error; |
15354 if (non_lvalue_p) | 15923 if (non_lvalue_p) |
15355 v = non_lvalue (v); | 15924 v = non_lvalue (v); |
15356 if (!c_parser_require (parser, CPP_EQ, "expected %<=%>")) | 15925 if (!c_parser_require (parser, CPP_EQ, "expected %<=%>")) |
15358 eloc = c_parser_peek_token (parser)->location; | 15927 eloc = c_parser_peek_token (parser)->location; |
15359 expr = c_parser_cast_expression (parser, NULL); | 15928 expr = c_parser_cast_expression (parser, NULL); |
15360 lhs1 = expr.value; | 15929 lhs1 = expr.value; |
15361 expr = default_function_array_read_conversion (eloc, expr); | 15930 expr = default_function_array_read_conversion (eloc, expr); |
15362 unfolded_lhs1 = expr.value; | 15931 unfolded_lhs1 = expr.value; |
15363 lhs1 = c_fully_fold (lhs1, false, NULL); | 15932 lhs1 = c_fully_fold (lhs1, false, NULL, true); |
15364 if (lhs1 == error_mark_node) | 15933 if (lhs1 == error_mark_node) |
15365 goto saw_error; | 15934 goto saw_error; |
15366 if (!lvalue_p (unfolded_lhs1)) | 15935 if (!lvalue_p (unfolded_lhs1)) |
15367 lhs1 = non_lvalue (lhs1); | 15936 lhs1 = non_lvalue (lhs1); |
15368 } | 15937 } |
15531 declv = make_tree_vec (count); | 16100 declv = make_tree_vec (count); |
15532 initv = make_tree_vec (count); | 16101 initv = make_tree_vec (count); |
15533 condv = make_tree_vec (count); | 16102 condv = make_tree_vec (count); |
15534 incrv = make_tree_vec (count); | 16103 incrv = make_tree_vec (count); |
15535 | 16104 |
15536 if (code != CILK_FOR | 16105 if (!c_parser_next_token_is_keyword (parser, RID_FOR)) |
15537 && !c_parser_next_token_is_keyword (parser, RID_FOR)) | |
15538 { | 16106 { |
15539 c_parser_error (parser, "for statement expected"); | 16107 c_parser_error (parser, "for statement expected"); |
15540 return NULL; | |
15541 } | |
15542 if (code == CILK_FOR | |
15543 && !c_parser_next_token_is_keyword (parser, RID_CILK_FOR)) | |
15544 { | |
15545 c_parser_error (parser, "_Cilk_for statement expected"); | |
15546 return NULL; | 16108 return NULL; |
15547 } | 16109 } |
15548 for_loc = c_parser_peek_token (parser)->location; | 16110 for_loc = c_parser_peek_token (parser)->location; |
15549 c_parser_consume_token (parser); | 16111 c_parser_consume_token (parser); |
15550 | 16112 |
15642 case GT_EXPR: | 16204 case GT_EXPR: |
15643 case GE_EXPR: | 16205 case GE_EXPR: |
15644 case LT_EXPR: | 16206 case LT_EXPR: |
15645 case LE_EXPR: | 16207 case LE_EXPR: |
15646 break; | 16208 break; |
15647 case NE_EXPR: | |
15648 if (code == CILK_SIMD || code == CILK_FOR) | |
15649 break; | |
15650 /* FALLTHRU. */ | |
15651 default: | 16209 default: |
15652 /* Can't be cond = error_mark_node, because we want to preserve | 16210 /* Can't be cond = error_mark_node, because we want to preserve |
15653 the location until c_finish_omp_for. */ | 16211 the location until c_finish_omp_for. */ |
15654 cond = build1 (NOP_EXPR, boolean_type_node, error_mark_node); | 16212 cond = build1 (NOP_EXPR, boolean_type_node, error_mark_node); |
15655 break; | 16213 break; |
15722 | 16280 |
15723 if (nbraces) | 16281 if (nbraces) |
15724 if_p = NULL; | 16282 if_p = NULL; |
15725 | 16283 |
15726 save_break = c_break_label; | 16284 save_break = c_break_label; |
15727 if (code == CILK_SIMD) | 16285 c_break_label = size_one_node; |
15728 c_break_label = build_int_cst (size_type_node, 2); | |
15729 else | |
15730 c_break_label = size_one_node; | |
15731 save_cont = c_cont_label; | 16286 save_cont = c_cont_label; |
15732 c_cont_label = NULL_TREE; | 16287 c_cont_label = NULL_TREE; |
15733 body = push_stmt_list (); | 16288 body = push_stmt_list (); |
15734 | 16289 |
15735 if (open_brace_parsed) | 16290 if (open_brace_parsed) |
17236 c_parser_declaration_or_fndef (parser, true, true, true, false, true, | 17791 c_parser_declaration_or_fndef (parser, true, true, true, false, true, |
17237 NULL, clauses); | 17792 NULL, clauses); |
17238 break; | 17793 break; |
17239 case pragma_struct: | 17794 case pragma_struct: |
17240 case pragma_param: | 17795 case pragma_param: |
17796 case pragma_stmt: | |
17241 c_parser_error (parser, "%<#pragma omp declare simd%> must be followed by " | 17797 c_parser_error (parser, "%<#pragma omp declare simd%> must be followed by " |
17242 "function declaration or definition"); | 17798 "function declaration or definition"); |
17243 break; | 17799 break; |
17244 case pragma_compound: | 17800 case pragma_compound: |
17245 case pragma_stmt: | |
17246 if (c_parser_next_token_is (parser, CPP_KEYWORD) | 17801 if (c_parser_next_token_is (parser, CPP_KEYWORD) |
17247 && c_parser_peek_token (parser)->keyword == RID_EXTENSION) | 17802 && c_parser_peek_token (parser)->keyword == RID_EXTENSION) |
17248 { | 17803 { |
17249 int ext = disable_extension_diagnostics (); | 17804 int ext = disable_extension_diagnostics (); |
17250 do | 17805 do |
17279 | 17834 |
17280 static void | 17835 static void |
17281 c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, | 17836 c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, |
17282 vec<c_token> clauses) | 17837 vec<c_token> clauses) |
17283 { | 17838 { |
17284 if (flag_cilkplus | |
17285 && (clauses.exists () | |
17286 || lookup_attribute ("simd", DECL_ATTRIBUTES (fndecl))) | |
17287 && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
17288 { | |
17289 error ("%<#pragma omp declare simd%> or %<simd%> attribute cannot be " | |
17290 "used in the same function marked as a Cilk Plus SIMD-enabled " | |
17291 "function"); | |
17292 vec_free (parser->cilk_simd_fn_tokens); | |
17293 return; | |
17294 } | |
17295 | |
17296 /* Normally first token is CPP_NAME "simd". CPP_EOF there indicates | 17839 /* Normally first token is CPP_NAME "simd". CPP_EOF there indicates |
17297 error has been reported and CPP_PRAGMA that c_finish_omp_declare_simd | 17840 error has been reported and CPP_PRAGMA that c_finish_omp_declare_simd |
17298 has already processed the tokens. */ | 17841 has already processed the tokens. */ |
17299 if (clauses.exists () && clauses[0].type == CPP_EOF) | 17842 if (clauses.exists () && clauses[0].type == CPP_EOF) |
17300 return; | 17843 return; |
17317 if (parms == NULL_TREE) | 17860 if (parms == NULL_TREE) |
17318 parms = DECL_ARGUMENTS (fndecl); | 17861 parms = DECL_ARGUMENTS (fndecl); |
17319 | 17862 |
17320 unsigned int tokens_avail = parser->tokens_avail; | 17863 unsigned int tokens_avail = parser->tokens_avail; |
17321 gcc_assert (parser->tokens == &parser->tokens_buf[0]); | 17864 gcc_assert (parser->tokens == &parser->tokens_buf[0]); |
17322 bool is_cilkplus_cilk_simd_fn = false; | |
17323 | 17865 |
17324 if (flag_cilkplus && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | 17866 |
17325 { | 17867 parser->tokens = clauses.address (); |
17326 parser->tokens = parser->cilk_simd_fn_tokens->address (); | 17868 parser->tokens_avail = clauses.length (); |
17327 parser->tokens_avail = vec_safe_length (parser->cilk_simd_fn_tokens); | |
17328 is_cilkplus_cilk_simd_fn = true; | |
17329 | |
17330 if (lookup_attribute ("simd", DECL_ATTRIBUTES (fndecl)) != NULL) | |
17331 { | |
17332 error_at (DECL_SOURCE_LOCATION (fndecl), | |
17333 "%<__simd__%> attribute cannot be used in the same " | |
17334 "function marked as a Cilk Plus SIMD-enabled function"); | |
17335 vec_free (parser->cilk_simd_fn_tokens); | |
17336 return; | |
17337 } | |
17338 | |
17339 } | |
17340 else | |
17341 { | |
17342 parser->tokens = clauses.address (); | |
17343 parser->tokens_avail = clauses.length (); | |
17344 } | |
17345 | 17869 |
17346 /* c_parser_omp_declare_simd pushed 2 extra CPP_EOF tokens at the end. */ | 17870 /* c_parser_omp_declare_simd pushed 2 extra CPP_EOF tokens at the end. */ |
17347 while (parser->tokens_avail > 3) | 17871 while (parser->tokens_avail > 3) |
17348 { | 17872 { |
17349 c_token *token = c_parser_peek_token (parser); | 17873 c_token *token = c_parser_peek_token (parser); |
17350 if (!is_cilkplus_cilk_simd_fn) | 17874 gcc_assert (token->type == CPP_NAME |
17351 gcc_assert (token->type == CPP_NAME | 17875 && strcmp (IDENTIFIER_POINTER (token->value), "simd") == 0); |
17352 && strcmp (IDENTIFIER_POINTER (token->value), "simd") == 0); | |
17353 else | |
17354 gcc_assert (token->type == CPP_NAME | |
17355 && is_cilkplus_vector_p (token->value)); | |
17356 c_parser_consume_token (parser); | 17876 c_parser_consume_token (parser); |
17357 parser->in_pragma = true; | 17877 parser->in_pragma = true; |
17358 | 17878 |
17359 tree c = NULL_TREE; | 17879 tree c = NULL_TREE; |
17360 if (is_cilkplus_cilk_simd_fn) | 17880 c = c_parser_omp_all_clauses (parser, OMP_DECLARE_SIMD_CLAUSE_MASK, |
17361 c = c_parser_omp_all_clauses (parser, CILK_SIMD_FN_CLAUSE_MASK, | |
17362 "SIMD-enabled functions attribute"); | |
17363 else | |
17364 c = c_parser_omp_all_clauses (parser, OMP_DECLARE_SIMD_CLAUSE_MASK, | |
17365 "#pragma omp declare simd"); | 17881 "#pragma omp declare simd"); |
17366 c = c_omp_declare_simd_clauses_to_numbers (parms, c); | 17882 c = c_omp_declare_simd_clauses_to_numbers (parms, c); |
17367 if (c != NULL_TREE) | 17883 if (c != NULL_TREE) |
17368 c = tree_cons (NULL_TREE, c, NULL_TREE); | 17884 c = tree_cons (NULL_TREE, c, NULL_TREE); |
17369 if (is_cilkplus_cilk_simd_fn) | |
17370 { | |
17371 tree k = build_tree_list (get_identifier ("cilk simd function"), | |
17372 NULL_TREE); | |
17373 TREE_CHAIN (k) = DECL_ATTRIBUTES (fndecl); | |
17374 DECL_ATTRIBUTES (fndecl) = k; | |
17375 } | |
17376 c = build_tree_list (get_identifier ("omp declare simd"), c); | 17885 c = build_tree_list (get_identifier ("omp declare simd"), c); |
17377 TREE_CHAIN (c) = DECL_ATTRIBUTES (fndecl); | 17886 TREE_CHAIN (c) = DECL_ATTRIBUTES (fndecl); |
17378 DECL_ATTRIBUTES (fndecl) = c; | 17887 DECL_ATTRIBUTES (fndecl) = c; |
17379 } | 17888 } |
17380 | 17889 |
17381 parser->tokens = &parser->tokens_buf[0]; | 17890 parser->tokens = &parser->tokens_buf[0]; |
17382 parser->tokens_avail = tokens_avail; | 17891 parser->tokens_avail = tokens_avail; |
17383 if (clauses.exists ()) | 17892 if (clauses.exists ()) |
17384 clauses[0].type = CPP_PRAGMA; | 17893 clauses[0].type = CPP_PRAGMA; |
17385 | |
17386 if (!vec_safe_is_empty (parser->cilk_simd_fn_tokens)) | |
17387 vec_free (parser->cilk_simd_fn_tokens); | |
17388 } | 17894 } |
17389 | 17895 |
17390 | 17896 |
17391 /* OpenMP 4.0: | 17897 /* OpenMP 4.0: |
17392 # pragma omp declare target new-line | 17898 # pragma omp declare target new-line |
17718 pushdecl (omp_in); | 18224 pushdecl (omp_in); |
17719 struct c_expr combiner = c_parser_expression (parser); | 18225 struct c_expr combiner = c_parser_expression (parser); |
17720 struct c_expr initializer; | 18226 struct c_expr initializer; |
17721 tree omp_priv = NULL_TREE, omp_orig = NULL_TREE; | 18227 tree omp_priv = NULL_TREE, omp_orig = NULL_TREE; |
17722 bool bad = false; | 18228 bool bad = false; |
17723 initializer.value = error_mark_node; | 18229 initializer.set_error (); |
17724 if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) | 18230 if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) |
17725 bad = true; | 18231 bad = true; |
17726 else if (c_parser_next_token_is (parser, CPP_NAME) | 18232 else if (c_parser_next_token_is (parser, CPP_NAME) |
17727 && strcmp (IDENTIFIER_POINTER | 18233 && strcmp (IDENTIFIER_POINTER |
17728 (c_parser_peek_token (parser)->value), | 18234 (c_parser_peek_token (parser)->value), |
18134 } | 18640 } |
18135 } | 18641 } |
18136 | 18642 |
18137 c_parser_skip_to_pragma_eol (parser); | 18643 c_parser_skip_to_pragma_eol (parser); |
18138 } | 18644 } |
18139 | 18645 |
18140 /* Cilk Plus <#pragma simd> parsing routines. */ | |
18141 | |
18142 /* Helper function for c_parser_pragma. Perform some sanity checking | |
18143 for <#pragma simd> constructs. Returns FALSE if there was a | |
18144 problem. */ | |
18145 | |
18146 static bool | |
18147 c_parser_cilk_verify_simd (c_parser *parser, | |
18148 enum pragma_context context) | |
18149 { | |
18150 if (!flag_cilkplus) | |
18151 { | |
18152 warning (0, "pragma simd ignored because -fcilkplus is not enabled"); | |
18153 c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); | |
18154 return false; | |
18155 } | |
18156 if (context == pragma_external) | |
18157 { | |
18158 c_parser_error (parser,"pragma simd must be inside a function"); | |
18159 c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); | |
18160 return false; | |
18161 } | |
18162 return true; | |
18163 } | |
18164 | |
18165 /* Cilk Plus: | |
18166 This function is shared by SIMD-enabled functions and #pragma simd. | |
18167 If IS_SIMD_FN is true then it is parsing a SIMD-enabled function and | |
18168 CLAUSES is unused. The main purpose of this function is to parse a | |
18169 vectorlength attribute or clause and check for parse errors. | |
18170 When IS_SIMD_FN is true then the function is merely caching the tokens | |
18171 in PARSER->CILK_SIMD_FN_TOKENS. If errors are found then the token | |
18172 cache is cleared since there is no reason to continue. | |
18173 Syntax: | |
18174 vectorlength ( constant-expression ) */ | |
18175 | |
18176 static tree | |
18177 c_parser_cilk_clause_vectorlength (c_parser *parser, tree clauses, | |
18178 bool is_simd_fn) | |
18179 { | |
18180 if (is_simd_fn) | |
18181 check_no_duplicate_clause (clauses, OMP_CLAUSE_SIMDLEN, "vectorlength"); | |
18182 else | |
18183 /* The vectorlength clause behaves exactly like OpenMP's safelen | |
18184 clause. Represent it in OpenMP terms. */ | |
18185 check_no_duplicate_clause (clauses, OMP_CLAUSE_SAFELEN, "vectorlength"); | |
18186 | |
18187 matching_parens parens; | |
18188 if (!parens.require_open (parser)) | |
18189 return clauses; | |
18190 | |
18191 location_t loc = c_parser_peek_token (parser)->location; | |
18192 tree expr = c_parser_expr_no_commas (parser, NULL).value; | |
18193 expr = c_fully_fold (expr, false, NULL); | |
18194 | |
18195 /* If expr is an error_mark_node then the above function would have | |
18196 emitted an error. No reason to do it twice. */ | |
18197 if (expr == error_mark_node) | |
18198 ; | |
18199 else if (!TREE_TYPE (expr) | |
18200 || !TREE_CONSTANT (expr) | |
18201 || !INTEGRAL_TYPE_P (TREE_TYPE (expr))) | |
18202 | |
18203 error_at (loc, "vectorlength must be an integer constant"); | |
18204 else if (wi::exact_log2 (wi::to_wide (expr)) == -1) | |
18205 error_at (loc, "vectorlength must be a power of 2"); | |
18206 else | |
18207 { | |
18208 if (is_simd_fn) | |
18209 { | |
18210 tree u = build_omp_clause (loc, OMP_CLAUSE_SIMDLEN); | |
18211 OMP_CLAUSE_SIMDLEN_EXPR (u) = expr; | |
18212 OMP_CLAUSE_CHAIN (u) = clauses; | |
18213 clauses = u; | |
18214 } | |
18215 else | |
18216 { | |
18217 tree u = build_omp_clause (loc, OMP_CLAUSE_SAFELEN); | |
18218 OMP_CLAUSE_SAFELEN_EXPR (u) = expr; | |
18219 OMP_CLAUSE_CHAIN (u) = clauses; | |
18220 clauses = u; | |
18221 } | |
18222 } | |
18223 | |
18224 parens.require_close (parser); | |
18225 | |
18226 return clauses; | |
18227 } | |
18228 | |
18229 /* Cilk Plus: | |
18230 linear ( simd-linear-variable-list ) | |
18231 | |
18232 simd-linear-variable-list: | |
18233 simd-linear-variable | |
18234 simd-linear-variable-list , simd-linear-variable | |
18235 | |
18236 simd-linear-variable: | |
18237 id-expression | |
18238 id-expression : simd-linear-step | |
18239 | |
18240 simd-linear-step: | |
18241 conditional-expression */ | |
18242 | |
18243 static tree | |
18244 c_parser_cilk_clause_linear (c_parser *parser, tree clauses) | |
18245 { | |
18246 matching_parens parens; | |
18247 if (!parens.require_open (parser)) | |
18248 return clauses; | |
18249 | |
18250 location_t loc = c_parser_peek_token (parser)->location; | |
18251 | |
18252 if (c_parser_next_token_is_not (parser, CPP_NAME) | |
18253 || c_parser_peek_token (parser)->id_kind != C_ID_ID) | |
18254 c_parser_error (parser, "expected identifier"); | |
18255 | |
18256 while (c_parser_next_token_is (parser, CPP_NAME) | |
18257 && c_parser_peek_token (parser)->id_kind == C_ID_ID) | |
18258 { | |
18259 tree var = lookup_name (c_parser_peek_token (parser)->value); | |
18260 | |
18261 if (var == NULL) | |
18262 { | |
18263 undeclared_variable (c_parser_peek_token (parser)->location, | |
18264 c_parser_peek_token (parser)->value); | |
18265 c_parser_consume_token (parser); | |
18266 } | |
18267 else if (var == error_mark_node) | |
18268 c_parser_consume_token (parser); | |
18269 else | |
18270 { | |
18271 tree step = integer_one_node; | |
18272 | |
18273 /* Parse the linear step if present. */ | |
18274 if (c_parser_peek_2nd_token (parser)->type == CPP_COLON) | |
18275 { | |
18276 c_parser_consume_token (parser); | |
18277 c_parser_consume_token (parser); | |
18278 | |
18279 tree expr = c_parser_expr_no_commas (parser, NULL).value; | |
18280 expr = c_fully_fold (expr, false, NULL); | |
18281 | |
18282 if (TREE_TYPE (expr) | |
18283 && INTEGRAL_TYPE_P (TREE_TYPE (expr)) | |
18284 && (TREE_CONSTANT (expr) | |
18285 || DECL_P (expr))) | |
18286 step = expr; | |
18287 else | |
18288 c_parser_error (parser, | |
18289 "step size must be an integer constant " | |
18290 "expression or an integer variable"); | |
18291 } | |
18292 else | |
18293 c_parser_consume_token (parser); | |
18294 | |
18295 /* Use OMP_CLAUSE_LINEAR, which has the same semantics. */ | |
18296 tree u = build_omp_clause (loc, OMP_CLAUSE_LINEAR); | |
18297 OMP_CLAUSE_DECL (u) = var; | |
18298 OMP_CLAUSE_LINEAR_STEP (u) = step; | |
18299 OMP_CLAUSE_CHAIN (u) = clauses; | |
18300 clauses = u; | |
18301 } | |
18302 | |
18303 if (c_parser_next_token_is_not (parser, CPP_COMMA)) | |
18304 break; | |
18305 | |
18306 c_parser_consume_token (parser); | |
18307 } | |
18308 | |
18309 parens.skip_until_found_close (parser); | |
18310 | |
18311 return clauses; | |
18312 } | |
18313 | |
18314 /* Returns the name of the next clause. If the clause is not | |
18315 recognized SIMD_OMP_CLAUSE_NONE is returned and the next token is | |
18316 not consumed. Otherwise, the appropriate pragma_simd_clause is | |
18317 returned and the token is consumed. */ | |
18318 | |
18319 static pragma_omp_clause | |
18320 c_parser_cilk_clause_name (c_parser *parser) | |
18321 { | |
18322 pragma_omp_clause result; | |
18323 c_token *token = c_parser_peek_token (parser); | |
18324 | |
18325 if (!token->value || token->type != CPP_NAME) | |
18326 return PRAGMA_CILK_CLAUSE_NONE; | |
18327 | |
18328 const char *p = IDENTIFIER_POINTER (token->value); | |
18329 | |
18330 if (!strcmp (p, "vectorlength")) | |
18331 result = PRAGMA_CILK_CLAUSE_VECTORLENGTH; | |
18332 else if (!strcmp (p, "linear")) | |
18333 result = PRAGMA_CILK_CLAUSE_LINEAR; | |
18334 else if (!strcmp (p, "private")) | |
18335 result = PRAGMA_CILK_CLAUSE_PRIVATE; | |
18336 else if (!strcmp (p, "firstprivate")) | |
18337 result = PRAGMA_CILK_CLAUSE_FIRSTPRIVATE; | |
18338 else if (!strcmp (p, "lastprivate")) | |
18339 result = PRAGMA_CILK_CLAUSE_LASTPRIVATE; | |
18340 else if (!strcmp (p, "reduction")) | |
18341 result = PRAGMA_CILK_CLAUSE_REDUCTION; | |
18342 else | |
18343 return PRAGMA_CILK_CLAUSE_NONE; | |
18344 | |
18345 c_parser_consume_token (parser); | |
18346 return result; | |
18347 } | |
18348 | |
18349 /* Parse all #<pragma simd> clauses. Return the list of clauses | |
18350 found. */ | |
18351 | |
18352 static tree | |
18353 c_parser_cilk_all_clauses (c_parser *parser) | |
18354 { | |
18355 tree clauses = NULL; | |
18356 | |
18357 while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) | |
18358 { | |
18359 pragma_omp_clause c_kind; | |
18360 | |
18361 c_kind = c_parser_cilk_clause_name (parser); | |
18362 | |
18363 switch (c_kind) | |
18364 { | |
18365 case PRAGMA_CILK_CLAUSE_VECTORLENGTH: | |
18366 clauses = c_parser_cilk_clause_vectorlength (parser, clauses, false); | |
18367 break; | |
18368 case PRAGMA_CILK_CLAUSE_LINEAR: | |
18369 clauses = c_parser_cilk_clause_linear (parser, clauses); | |
18370 break; | |
18371 case PRAGMA_CILK_CLAUSE_PRIVATE: | |
18372 /* Use the OpenMP counterpart. */ | |
18373 clauses = c_parser_omp_clause_private (parser, clauses); | |
18374 break; | |
18375 case PRAGMA_CILK_CLAUSE_FIRSTPRIVATE: | |
18376 /* Use the OpenMP counterpart. */ | |
18377 clauses = c_parser_omp_clause_firstprivate (parser, clauses); | |
18378 break; | |
18379 case PRAGMA_CILK_CLAUSE_LASTPRIVATE: | |
18380 /* Use the OpenMP counterpart. */ | |
18381 clauses = c_parser_omp_clause_lastprivate (parser, clauses); | |
18382 break; | |
18383 case PRAGMA_CILK_CLAUSE_REDUCTION: | |
18384 /* Use the OpenMP counterpart. */ | |
18385 clauses = c_parser_omp_clause_reduction (parser, clauses); | |
18386 break; | |
18387 default: | |
18388 c_parser_error (parser, "expected %<#pragma simd%> clause"); | |
18389 goto saw_error; | |
18390 } | |
18391 } | |
18392 | |
18393 saw_error: | |
18394 c_parser_skip_to_pragma_eol (parser); | |
18395 return c_finish_omp_clauses (clauses, C_ORT_CILK); | |
18396 } | |
18397 | |
18398 /* This function helps parse the grainsize pragma for a _Cilk_for statement. | |
18399 Here is the correct syntax of this pragma: | |
18400 #pragma cilk grainsize = <EXP> | |
18401 */ | |
18402 | |
18403 static void | |
18404 c_parser_cilk_grainsize (c_parser *parser, bool *if_p) | |
18405 { | |
18406 extern tree convert_to_integer (tree, tree); | |
18407 | |
18408 /* consume the 'grainsize' keyword. */ | |
18409 c_parser_consume_pragma (parser); | |
18410 | |
18411 if (c_parser_require (parser, CPP_EQ, "expected %<=%>") != 0) | |
18412 { | |
18413 struct c_expr g_expr = c_parser_binary_expression (parser, NULL, NULL); | |
18414 if (g_expr.value == error_mark_node) | |
18415 { | |
18416 c_parser_skip_to_pragma_eol (parser); | |
18417 return; | |
18418 } | |
18419 tree grain = convert_to_integer (long_integer_type_node, | |
18420 c_fully_fold (g_expr.value, false, | |
18421 NULL)); | |
18422 c_parser_skip_to_pragma_eol (parser); | |
18423 c_token *token = c_parser_peek_token (parser); | |
18424 if (token && token->type == CPP_KEYWORD | |
18425 && token->keyword == RID_CILK_FOR) | |
18426 { | |
18427 if (grain == NULL_TREE || grain == error_mark_node) | |
18428 grain = integer_zero_node; | |
18429 c_parser_cilk_for (parser, grain, if_p); | |
18430 } | |
18431 else | |
18432 warning (0, "%<#pragma cilk grainsize%> is not followed by " | |
18433 "%<_Cilk_for%>"); | |
18434 } | |
18435 else | |
18436 c_parser_skip_to_pragma_eol (parser); | |
18437 } | |
18438 | |
18439 /* Main entry point for parsing Cilk Plus <#pragma simd> for loops. */ | |
18440 | |
18441 static void | |
18442 c_parser_cilk_simd (c_parser *parser, bool *if_p) | |
18443 { | |
18444 tree clauses = c_parser_cilk_all_clauses (parser); | |
18445 tree block = c_begin_compound_stmt (true); | |
18446 location_t loc = c_parser_peek_token (parser)->location; | |
18447 c_parser_omp_for_loop (loc, parser, CILK_SIMD, clauses, NULL, if_p); | |
18448 block = c_end_compound_stmt (loc, block, true); | |
18449 add_stmt (block); | |
18450 } | |
18451 | |
18452 /* Create an artificial decl with TYPE and emit initialization of it with | |
18453 INIT. */ | |
18454 | |
18455 static tree | |
18456 c_get_temp_regvar (tree type, tree init) | |
18457 { | |
18458 location_t loc = EXPR_LOCATION (init); | |
18459 tree decl = build_decl (loc, VAR_DECL, NULL_TREE, type); | |
18460 DECL_ARTIFICIAL (decl) = 1; | |
18461 DECL_IGNORED_P (decl) = 1; | |
18462 pushdecl (decl); | |
18463 tree t = build2 (INIT_EXPR, type, decl, init); | |
18464 add_stmt (t); | |
18465 return decl; | |
18466 } | |
18467 | |
18468 /* Main entry point for parsing Cilk Plus _Cilk_for loops. | |
18469 GRAIN is the grain value passed in through pragma or 0. */ | |
18470 | |
18471 static void | |
18472 c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p) | |
18473 { | |
18474 tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE); | |
18475 OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR; | |
18476 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain; | |
18477 clauses = c_finish_omp_clauses (clauses, C_ORT_CILK); | |
18478 | |
18479 tree block = c_begin_compound_stmt (true); | |
18480 tree sb = push_stmt_list (); | |
18481 location_t loc = c_parser_peek_token (parser)->location; | |
18482 tree omp_for = c_parser_omp_for_loop (loc, parser, CILK_FOR, clauses, NULL, | |
18483 if_p); | |
18484 sb = pop_stmt_list (sb); | |
18485 | |
18486 if (omp_for) | |
18487 { | |
18488 tree omp_par = make_node (OMP_PARALLEL); | |
18489 TREE_TYPE (omp_par) = void_type_node; | |
18490 OMP_PARALLEL_CLAUSES (omp_par) = NULL_TREE; | |
18491 tree bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL); | |
18492 TREE_SIDE_EFFECTS (bind) = 1; | |
18493 BIND_EXPR_BODY (bind) = sb; | |
18494 OMP_PARALLEL_BODY (omp_par) = bind; | |
18495 if (OMP_FOR_PRE_BODY (omp_for)) | |
18496 { | |
18497 add_stmt (OMP_FOR_PRE_BODY (omp_for)); | |
18498 OMP_FOR_PRE_BODY (omp_for) = NULL_TREE; | |
18499 } | |
18500 tree init = TREE_VEC_ELT (OMP_FOR_INIT (omp_for), 0); | |
18501 tree decl = TREE_OPERAND (init, 0); | |
18502 tree cond = TREE_VEC_ELT (OMP_FOR_COND (omp_for), 0); | |
18503 tree incr = TREE_VEC_ELT (OMP_FOR_INCR (omp_for), 0); | |
18504 tree t = TREE_OPERAND (cond, 1), c, clauses = NULL_TREE; | |
18505 if (TREE_CODE (t) != INTEGER_CST) | |
18506 { | |
18507 TREE_OPERAND (cond, 1) = c_get_temp_regvar (TREE_TYPE (t), t); | |
18508 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
18509 OMP_CLAUSE_DECL (c) = TREE_OPERAND (cond, 1); | |
18510 OMP_CLAUSE_CHAIN (c) = clauses; | |
18511 clauses = c; | |
18512 } | |
18513 if (TREE_CODE (incr) == MODIFY_EXPR) | |
18514 { | |
18515 t = TREE_OPERAND (TREE_OPERAND (incr, 1), 1); | |
18516 if (TREE_CODE (t) != INTEGER_CST) | |
18517 { | |
18518 TREE_OPERAND (TREE_OPERAND (incr, 1), 1) | |
18519 = c_get_temp_regvar (TREE_TYPE (t), t); | |
18520 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
18521 OMP_CLAUSE_DECL (c) = TREE_OPERAND (TREE_OPERAND (incr, 1), 1); | |
18522 OMP_CLAUSE_CHAIN (c) = clauses; | |
18523 clauses = c; | |
18524 } | |
18525 } | |
18526 t = TREE_OPERAND (init, 1); | |
18527 if (TREE_CODE (t) != INTEGER_CST) | |
18528 { | |
18529 TREE_OPERAND (init, 1) = c_get_temp_regvar (TREE_TYPE (t), t); | |
18530 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
18531 OMP_CLAUSE_DECL (c) = TREE_OPERAND (init, 1); | |
18532 OMP_CLAUSE_CHAIN (c) = clauses; | |
18533 clauses = c; | |
18534 } | |
18535 c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); | |
18536 OMP_CLAUSE_DECL (c) = decl; | |
18537 OMP_CLAUSE_CHAIN (c) = clauses; | |
18538 clauses = c; | |
18539 c = build_omp_clause (input_location, OMP_CLAUSE__CILK_FOR_COUNT_); | |
18540 OMP_CLAUSE_OPERAND (c, 0) | |
18541 = cilk_for_number_of_iterations (omp_for); | |
18542 OMP_CLAUSE_CHAIN (c) = clauses; | |
18543 OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, C_ORT_CILK); | |
18544 add_stmt (omp_par); | |
18545 } | |
18546 | |
18547 block = c_end_compound_stmt (loc, block, true); | |
18548 add_stmt (block); | |
18549 } | |
18550 | |
18551 | |
18552 /* Parse a transaction attribute (GCC Extension). | 18646 /* Parse a transaction attribute (GCC Extension). |
18553 | 18647 |
18554 transaction-attribute: | 18648 transaction-attribute: |
18555 attributes | 18649 attributes |
18556 [ [ any-word ] ] | 18650 [ [ any-word ] ] |
18687 } | 18781 } |
18688 } | 18782 } |
18689 else | 18783 else |
18690 { | 18784 { |
18691 error: | 18785 error: |
18692 ret.value = error_mark_node; | 18786 ret.set_error (); |
18693 ret.original_code = ERROR_MARK; | 18787 ret.original_code = ERROR_MARK; |
18694 ret.original_type = NULL; | 18788 ret.original_type = NULL; |
18695 } | 18789 } |
18696 parser->in_transaction = old_in; | 18790 parser->in_transaction = old_in; |
18697 | 18791 |
18790 if (flag_exceptions) | 18884 if (flag_exceptions) |
18791 using_eh_for_cleanups (); | 18885 using_eh_for_cleanups (); |
18792 | 18886 |
18793 c_parser_translation_unit (the_parser); | 18887 c_parser_translation_unit (the_parser); |
18794 the_parser = NULL; | 18888 the_parser = NULL; |
18795 } | |
18796 | |
18797 /* This function parses Cilk Plus array notation. The starting index is | |
18798 passed in INITIAL_INDEX and the array name is passes in ARRAY_VALUE. The | |
18799 return value of this function is a tree_node called VALUE_TREE of type | |
18800 ARRAY_NOTATION_REF. */ | |
18801 | |
18802 static tree | |
18803 c_parser_array_notation (location_t loc, c_parser *parser, tree initial_index, | |
18804 tree array_value) | |
18805 { | |
18806 c_token *token = NULL; | |
18807 tree start_index = NULL_TREE, end_index = NULL_TREE, stride = NULL_TREE; | |
18808 tree value_tree = NULL_TREE, type = NULL_TREE, array_type = NULL_TREE; | |
18809 tree array_type_domain = NULL_TREE; | |
18810 | |
18811 if (array_value == error_mark_node || initial_index == error_mark_node) | |
18812 { | |
18813 /* No need to continue. If either of these 2 were true, then an error | |
18814 must be emitted already. Thus, no need to emit them twice. */ | |
18815 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18816 return error_mark_node; | |
18817 } | |
18818 | |
18819 array_type = TREE_TYPE (array_value); | |
18820 gcc_assert (array_type); | |
18821 if (TREE_CODE (array_type) != ARRAY_TYPE | |
18822 && TREE_CODE (array_type) != POINTER_TYPE) | |
18823 { | |
18824 error_at (loc, "base of array section must be pointer or array type"); | |
18825 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18826 return error_mark_node; | |
18827 } | |
18828 type = TREE_TYPE (array_type); | |
18829 token = c_parser_peek_token (parser); | |
18830 | |
18831 if (token->type == CPP_EOF) | |
18832 { | |
18833 c_parser_error (parser, "expected %<:%> or numeral"); | |
18834 return value_tree; | |
18835 } | |
18836 else if (token->type == CPP_COLON) | |
18837 { | |
18838 if (!initial_index) | |
18839 { | |
18840 /* If we are here, then we have a case like this A[:]. */ | |
18841 c_parser_consume_token (parser); | |
18842 if (TREE_CODE (array_type) == POINTER_TYPE) | |
18843 { | |
18844 error_at (loc, "start-index and length fields necessary for " | |
18845 "using array notations in pointers"); | |
18846 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18847 return error_mark_node; | |
18848 } | |
18849 if (TREE_CODE (array_type) == FUNCTION_TYPE) | |
18850 { | |
18851 error_at (loc, "array notations cannot be used with function " | |
18852 "type"); | |
18853 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18854 return error_mark_node; | |
18855 } | |
18856 array_type_domain = TYPE_DOMAIN (array_type); | |
18857 | |
18858 if (!array_type_domain) | |
18859 { | |
18860 error_at (loc, "start-index and length fields necessary for " | |
18861 "using array notations in dimensionless arrays"); | |
18862 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18863 return error_mark_node; | |
18864 } | |
18865 | |
18866 start_index = TYPE_MIN_VALUE (array_type_domain); | |
18867 start_index = fold_build1 (CONVERT_EXPR, ptrdiff_type_node, | |
18868 start_index); | |
18869 if (!TYPE_MAX_VALUE (array_type_domain) | |
18870 || !TREE_CONSTANT (TYPE_MAX_VALUE (array_type_domain))) | |
18871 { | |
18872 error_at (loc, "start-index and length fields necessary for " | |
18873 "using array notations in variable-length arrays"); | |
18874 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18875 return error_mark_node; | |
18876 } | |
18877 end_index = TYPE_MAX_VALUE (array_type_domain); | |
18878 end_index = fold_build2 (PLUS_EXPR, TREE_TYPE (end_index), | |
18879 end_index, integer_one_node); | |
18880 end_index = fold_build1 (CONVERT_EXPR, ptrdiff_type_node, end_index); | |
18881 stride = build_int_cst (integer_type_node, 1); | |
18882 stride = fold_build1 (CONVERT_EXPR, ptrdiff_type_node, stride); | |
18883 } | |
18884 else if (initial_index != error_mark_node) | |
18885 { | |
18886 /* If we are here, then there should be 2 possibilities: | |
18887 1. Array [EXPR : EXPR] | |
18888 2. Array [EXPR : EXPR : EXPR] | |
18889 */ | |
18890 start_index = initial_index; | |
18891 | |
18892 if (TREE_CODE (array_type) == FUNCTION_TYPE) | |
18893 { | |
18894 error_at (loc, "array notations cannot be used with function " | |
18895 "type"); | |
18896 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL); | |
18897 return error_mark_node; | |
18898 } | |
18899 c_parser_consume_token (parser); /* consume the ':' */ | |
18900 struct c_expr ce = c_parser_expression (parser); | |
18901 ce = convert_lvalue_to_rvalue (loc, ce, false, false); | |
18902 end_index = ce.value; | |
18903 if (!end_index || end_index == error_mark_node) | |
18904 { | |
18905 c_parser_skip_to_end_of_block_or_statement (parser); | |
18906 return error_mark_node; | |
18907 } | |
18908 if (c_parser_peek_token (parser)->type == CPP_COLON) | |
18909 { | |
18910 c_parser_consume_token (parser); | |
18911 ce = c_parser_expression (parser); | |
18912 ce = convert_lvalue_to_rvalue (loc, ce, false, false); | |
18913 stride = ce.value; | |
18914 if (!stride || stride == error_mark_node) | |
18915 { | |
18916 c_parser_skip_to_end_of_block_or_statement (parser); | |
18917 return error_mark_node; | |
18918 } | |
18919 } | |
18920 } | |
18921 else | |
18922 c_parser_error (parser, "expected array notation expression"); | |
18923 } | |
18924 else | |
18925 c_parser_error (parser, "expected array notation expression"); | |
18926 | |
18927 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, "expected %<]%>"); | |
18928 | |
18929 value_tree = build_array_notation_ref (loc, array_value, start_index, | |
18930 end_index, stride, type); | |
18931 if (value_tree != error_mark_node) | |
18932 SET_EXPR_LOCATION (value_tree, loc); | |
18933 return value_tree; | |
18934 } | 18889 } |
18935 | 18890 |
18936 /* Parse the body of a function declaration marked with "__RTL". | 18891 /* Parse the body of a function declaration marked with "__RTL". |
18937 | 18892 |
18938 The RTL parser works on the level of characters read from a | 18893 The RTL parser works on the level of characters read from a |