aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-09-27 22:14:24 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-09-27 22:14:24 +0200
commit59bc434a3327ce58f7afcd1e9209eeb2da714960 (patch)
treec3c66425e42402e1f978eae510ebd6cb4a617da7 /gcc/c/c-parser.c
parent00798c58439037e3de959c3a003d6f4251eb93c6 (diff)
downloadgcc-59bc434a3327ce58f7afcd1e9209eeb2da714960.zip
gcc-59bc434a3327ce58f7afcd1e9209eeb2da714960.tar.gz
gcc-59bc434a3327ce58f7afcd1e9209eeb2da714960.tar.bz2
re PR c++/88203 (assert does not compile with OpenMP's pragma omp parallel for default(none))
PR c++/88203 c-family/ * c-common.h (c_omp_predefined_variable): Declare. * c-omp.c (c_omp_predefined_variable): New function. (c_omp_predetermined_sharing): Return OMP_CLAUSE_DEFAULT_SHARED for predefined variables. c/ * c-parser.c (c_parser_predefined_identifier): New function. (c_parser_postfix_expression): Use it. (c_parser_omp_variable_list): Parse predefined identifiers. * c-typeck.c (c_finish_omp_clauses): Allow predefined variables in shared and firstprivate clauses, even when they are predetermined shared. cp/ * parser.c (cp_parser_omp_var_list_no_open): Parse predefined variables. * semantics.c (finish_omp_clauses): Allow predefined variables in shared and firstprivate clauses, even when they are predetermined shared. * cp-gimplify.c (cxx_omp_predetermined_sharing_1): Return OMP_CLAUSE_DEFAULT_SHARED for predefined variables. testsuite/ * c-c++-common/gomp/pr88203-1.c: New test. * c-c++-common/gomp/pr88203-2.c: New test. * c-c++-common/gomp/pr88203-3.c: New test. From-SVN: r276212
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c104
1 files changed, 66 insertions, 38 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 6070502..c8afab2 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -8049,6 +8049,41 @@ enum tgmath_parm_kind
tgmath_fixed, tgmath_real, tgmath_complex
};
+/* Helper function for c_parser_postfix_expression. Parse predefined
+ identifiers. */
+
+static struct c_expr
+c_parser_predefined_identifier (c_parser *parser)
+{
+ location_t loc = c_parser_peek_token (parser)->location;
+ switch (c_parser_peek_token (parser)->keyword)
+ {
+ case RID_FUNCTION_NAME:
+ pedwarn (loc, OPT_Wpedantic, "ISO C does not support %qs predefined "
+ "identifier", "__FUNCTION__");
+ break;
+ case RID_PRETTY_FUNCTION_NAME:
+ pedwarn (loc, OPT_Wpedantic, "ISO C does not support %qs predefined "
+ "identifier", "__PRETTY_FUNCTION__");
+ break;
+ case RID_C99_FUNCTION_NAME:
+ pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support "
+ "%<__func__%> predefined identifier");
+ break;
+ default:
+ gcc_unreachable ();
+ }
+
+ struct c_expr expr;
+ expr.original_code = ERROR_MARK;
+ expr.original_type = NULL;
+ expr.value = fname_decl (loc, c_parser_peek_token (parser)->keyword,
+ c_parser_peek_token (parser)->value);
+ set_c_expr_source_range (&expr, loc, loc);
+ c_parser_consume_token (parser);
+ return expr;
+}
+
/* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2,
C11 6.5.1-6.5.2). Compound literals aren't handled here; callers have to
call c_parser_postfix_expression_after_paren_type on encountering them.
@@ -8269,31 +8304,9 @@ c_parser_postfix_expression (c_parser *parser)
switch (c_parser_peek_token (parser)->keyword)
{
case RID_FUNCTION_NAME:
- pedwarn (loc, OPT_Wpedantic, "ISO C does not support "
- "%<__FUNCTION__%> predefined identifier");
- expr.value = fname_decl (loc,
- c_parser_peek_token (parser)->keyword,
- c_parser_peek_token (parser)->value);
- set_c_expr_source_range (&expr, loc, loc);
- c_parser_consume_token (parser);
- break;
case RID_PRETTY_FUNCTION_NAME:
- pedwarn (loc, OPT_Wpedantic, "ISO C does not support "
- "%<__PRETTY_FUNCTION__%> predefined identifier");
- expr.value = fname_decl (loc,
- c_parser_peek_token (parser)->keyword,
- c_parser_peek_token (parser)->value);
- set_c_expr_source_range (&expr, loc, loc);
- c_parser_consume_token (parser);
- break;
case RID_C99_FUNCTION_NAME:
- pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support "
- "%<__func__%> predefined identifier");
- expr.value = fname_decl (loc,
- c_parser_peek_token (parser)->keyword,
- c_parser_peek_token (parser)->value);
- set_c_expr_source_range (&expr, loc, loc);
- c_parser_consume_token (parser);
+ expr = c_parser_predefined_identifier (parser);
break;
case RID_VA_ARG:
{
@@ -11997,15 +12010,9 @@ c_parser_omp_variable_list (c_parser *parser,
{
auto_vec<c_token> tokens;
unsigned int tokens_avail = 0;
+ bool first = true;
- if (kind != OMP_CLAUSE_DEPEND
- && (c_parser_next_token_is_not (parser, CPP_NAME)
- || c_parser_peek_token (parser)->id_kind != C_ID_ID))
- c_parser_error (parser, "expected identifier");
-
- while (kind == OMP_CLAUSE_DEPEND
- || (c_parser_next_token_is (parser, CPP_NAME)
- && c_parser_peek_token (parser)->id_kind == C_ID_ID))
+ while (1)
{
bool array_section_p = false;
if (kind == OMP_CLAUSE_DEPEND)
@@ -12026,6 +12033,7 @@ c_parser_omp_variable_list (c_parser *parser,
break;
c_parser_consume_token (parser);
+ first = false;
continue;
}
@@ -12076,16 +12084,35 @@ c_parser_omp_variable_list (c_parser *parser,
parser->tokens_avail = tokens.length ();
}
- tree t = lookup_name (c_parser_peek_token (parser)->value);
+ tree t = NULL_TREE;
- if (t == NULL_TREE)
+ if (c_parser_next_token_is (parser, CPP_NAME)
+ && c_parser_peek_token (parser)->id_kind == C_ID_ID)
{
- undeclared_variable (c_parser_peek_token (parser)->location,
- c_parser_peek_token (parser)->value);
- t = error_mark_node;
- }
+ t = lookup_name (c_parser_peek_token (parser)->value);
- c_parser_consume_token (parser);
+ if (t == NULL_TREE)
+ {
+ undeclared_variable (c_parser_peek_token (parser)->location,
+ c_parser_peek_token (parser)->value);
+ t = error_mark_node;
+ }
+
+ c_parser_consume_token (parser);
+ }
+ else if (c_parser_next_token_is (parser, CPP_KEYWORD)
+ && (c_parser_peek_token (parser)->keyword == RID_FUNCTION_NAME
+ || (c_parser_peek_token (parser)->keyword
+ == RID_PRETTY_FUNCTION_NAME)
+ || (c_parser_peek_token (parser)->keyword
+ == RID_C99_FUNCTION_NAME)))
+ t = c_parser_predefined_identifier (parser).value;
+ else
+ {
+ if (first)
+ c_parser_error (parser, "expected identifier");
+ break;
+ }
if (t == error_mark_node)
;
@@ -12223,6 +12250,7 @@ c_parser_omp_variable_list (c_parser *parser,
break;
c_parser_consume_token (parser);
+ first = false;
}
return list;