openmp: Actually ignore pragma_stmt pragmas for which c_parser_pragma returns false

Unlike the C++ FE, the C FE ignored pragmas (as if they weren't there) in
pragma_stmt contexts if c*_parser_pragma returns false only when after labels,
not inside of substatements of selection or loop statements.
After making just that change, several gomp/goacc testcases started failing,
because extra diagnostics has been emitted (in C, in C++ it was emitted
already before).  Say
void
foo (int x)
{
  if (x)
    #pragma omp barrier
}
used to in C emit just an error that the pragma is not allowed in such
contexts, but in C++ emitted both that and a parsing error that
  if (x)
}
is invalid.  So, the rest of this patch is mostly about returning true
after we report that that certain pragma is not allowed in pragma_stmt
contexts, because for error-recovery it seems better to treat the
pragma in that case as something that is the substatement of such if etc.
c*_parser_pragma return value is only ever used for pragma_stmt context,
in which false means act as if the pragma isn't there (e.g. has been handled
already by preprocessor etc.), and true which means it was there.

2021-08-18  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
	* c-parser.c (c_parser_statement_after_labels): Add restart label
	near the start of the function.  If c_parser_pragma returns false,
	goto restart.
	(c_parser_pragma): For PRAGMA_OMP_CANCELLATION_POINT return what
	c_parser_omp_cancellation_point returned.  For PRAGMA_OMP_DECLARE
	return what c_parser_omp_declare returned.  Return true instead of
	false after emitting errors that the directive is not allowed in
	pragma_stmt context.
	(c_parser_omp_ordered): Return true instead of
	false after emitting errors that the directive is not allowed in
	pragma_stmt context.
	(c_parser_omp_target_update): Likewise.
	(c_parser_omp_target_enter_data, c_parser_omp_target_exit_data):
	Change return type from tree to bool, return false if the
	directive should be ignored in pragma_stmt contexts.
	(c_parser_omp_target): Adjust callers of c_parser_omp_target_*_data,
	return their result directly.
	(c_parser_omp_cancellation_point): Change return type from void to
	bool, return false if the directive should be ignored in pragma_stmt
	contexts.
	(c_parser_omp_declare): Likewise.
gcc/cp/
	* parser.c (cp_parser_omp_ordered): Return true instead of
	false after emitting errors that the directive is not allowed in
	pragma_stmt context.
	(cp_parser_omp_target_update): Likewise.
	(cp_parser_omp_cancellation_point): Change return type from void to
	bool, return false if the directive should be ignored in pragma_stmt
	contexts.
	(cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data):
	Change return type from tree to bool, return false if the
	directive should be ignored in pragma_stmt contexts.
	(cp_parser_omp_target): Adjust callers of cp_parser_omp_target_*_data,
	return their result directly.
	(cp_parser_pragma): For PRAGMA_OMP_CANCELLATION_POINT return what
	cp_parser_omp_cancellation_point returned.  Return true instead of
	false after emitting errors that the directive is not allowed in
	pragma_stmt context.
gcc/testsuite/
	* c-c++-common/gomp/pr63326.c: Don't expect extra "before" errors
	in C++.
	* g++.dg/gomp/attrs-7.C: Don't expect one extra error.
	* g++.dg/gomp/barrier-2.C: Likewise.
	* gcc.dg/gomp/declare-simd-5.c: Likewise.
	* gcc.dg/gomp/barrier-2.c: Likewise.
	* gcc.dg/gomp/declare-variant-2.c: Likewise.
This commit is contained in:
Jakub Jelinek 2021-08-18 10:20:50 +02:00
parent 97d51c1764
commit 1bf976a5de
8 changed files with 99 additions and 89 deletions

View File

@ -1582,10 +1582,10 @@ static void c_parser_omp_cancel (c_parser *);
enum pragma_context { pragma_external, pragma_struct, pragma_param,
pragma_stmt, pragma_compound };
static bool c_parser_pragma (c_parser *, enum pragma_context, bool *);
static void c_parser_omp_cancellation_point (c_parser *, enum pragma_context);
static bool c_parser_omp_cancellation_point (c_parser *, enum pragma_context);
static bool c_parser_omp_target (c_parser *, enum pragma_context, bool *);
static void c_parser_omp_end_declare_target (c_parser *);
static void c_parser_omp_declare (c_parser *, enum pragma_context);
static bool c_parser_omp_declare (c_parser *, enum pragma_context);
static void c_parser_omp_requires (c_parser *);
static bool c_parser_omp_ordered (c_parser *, enum pragma_context, bool *);
static void c_parser_oacc_routine (c_parser *, enum pragma_context);
@ -6100,6 +6100,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p,
if (c_parser_peek_token (parser)->type != CPP_OPEN_BRACE)
add_debug_begin_stmt (loc);
restart:
switch (c_parser_peek_token (parser)->type)
{
case CPP_OPEN_BRACE:
@ -6246,7 +6247,8 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p,
c_parser_consume_token (parser);
break;
case CPP_PRAGMA:
c_parser_pragma (parser, pragma_stmt, if_p);
if (!c_parser_pragma (parser, pragma_stmt, if_p))
goto restart;
break;
default:
expr_stmt:
@ -12346,7 +12348,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
"%<#pragma %s%> may only be used in compound "
"statements", construct);
c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
return false;
return true;
}
goto bad_stmt;
}
@ -12437,8 +12439,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
return false;
case PRAGMA_OMP_CANCELLATION_POINT:
c_parser_omp_cancellation_point (parser, context);
return false;
return c_parser_omp_cancellation_point (parser, context);
case PRAGMA_OMP_THREADPRIVATE:
c_parser_omp_threadprivate (parser);
@ -12466,8 +12467,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
return false;
case PRAGMA_OMP_DECLARE:
c_parser_omp_declare (parser, context);
return false;
return c_parser_omp_declare (parser, context);
case PRAGMA_OMP_REQUIRES:
if (context != pragma_external)
@ -12505,7 +12505,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
else
c_parser_do_statement (parser, ivdep, unroll);
}
return false;
return true;
case PRAGMA_UNROLL:
{
@ -12529,7 +12529,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
else
c_parser_do_statement (parser, ivdep, unroll);
}
return false;
return true;
case PRAGMA_GCC_PCH_PREPROCESS:
c_parser_error (parser, "%<#pragma GCC pch_preprocess%> must be first");
@ -19125,7 +19125,7 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context,
"%<#pragma omp ordered%> with %<depend%> clause may "
"only be used in compound statements");
c_parser_skip_to_pragma_eol (parser, false);
return false;
return true;
}
tree clauses
@ -19655,7 +19655,7 @@ c_parser_omp_cancel (c_parser *parser)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SECTIONS) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASKGROUP))
static void
static bool
c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context)
{
location_t loc = c_parser_peek_token (parser)->location;
@ -19676,7 +19676,7 @@ c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context)
{
c_parser_error (parser, "expected %<point%>");
c_parser_skip_to_pragma_eol (parser);
return;
return false;
}
if (context != pragma_compound)
@ -19688,7 +19688,7 @@ c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context)
else
c_parser_error (parser, "expected declaration specifiers");
c_parser_skip_to_pragma_eol (parser, false);
return;
return true;
}
clauses
@ -19696,6 +19696,7 @@ c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context)
"#pragma omp cancellation point");
c_finish_omp_cancellation_point (loc, clauses);
return true;
}
/* OpenMP 4.0:
@ -19981,7 +19982,7 @@ c_parser_omp_target_update (location_t loc, c_parser *parser,
error_at (loc, "%<#pragma %s%> may only be used in compound statements",
"omp target update");
c_parser_skip_to_pragma_eol (parser, false);
return false;
return true;
}
tree clauses
@ -20014,7 +20015,7 @@ c_parser_omp_target_update (location_t loc, c_parser *parser,
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
static bool
c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
enum pragma_context context)
{
@ -20032,7 +20033,7 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
{
c_parser_error (parser, "expected %<data%>");
c_parser_skip_to_pragma_eol (parser);
return NULL_TREE;
return false;
}
if (context == pragma_stmt)
@ -20040,7 +20041,7 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
error_at (loc, "%<#pragma %s%> may only be used in compound statements",
"omp target enter data");
c_parser_skip_to_pragma_eol (parser, false);
return NULL_TREE;
return true;
}
tree clauses
@ -20079,7 +20080,7 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
error_at (loc,
"%<#pragma omp target enter data%> must contain at least "
"one %<map%> clause");
return NULL_TREE;
return true;
}
tree stmt = make_node (OMP_TARGET_ENTER_DATA);
@ -20087,7 +20088,7 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
OMP_TARGET_ENTER_DATA_CLAUSES (stmt) = clauses;
SET_EXPR_LOCATION (stmt, loc);
add_stmt (stmt);
return stmt;
return true;
}
/* OpenMP 4.5:
@ -20100,7 +20101,7 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
static bool
c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
enum pragma_context context)
{
@ -20118,7 +20119,7 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
{
c_parser_error (parser, "expected %<data%>");
c_parser_skip_to_pragma_eol (parser);
return NULL_TREE;
return false;
}
if (context == pragma_stmt)
@ -20126,7 +20127,7 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
error_at (loc, "%<#pragma %s%> may only be used in compound statements",
"omp target exit data");
c_parser_skip_to_pragma_eol (parser, false);
return NULL_TREE;
return true;
}
tree clauses
@ -20167,7 +20168,7 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
error_at (loc,
"%<#pragma omp target exit data%> must contain at least one "
"%<map%> clause");
return NULL_TREE;
return true;
}
tree stmt = make_node (OMP_TARGET_EXIT_DATA);
@ -20175,7 +20176,7 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
OMP_TARGET_EXIT_DATA_CLAUSES (stmt) = clauses;
SET_EXPR_LOCATION (stmt, loc);
add_stmt (stmt);
return stmt;
return true;
}
/* OpenMP 4.0:
@ -20333,14 +20334,12 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p)
else if (strcmp (p, "enter") == 0)
{
c_parser_consume_token (parser);
c_parser_omp_target_enter_data (loc, parser, context);
return false;
return c_parser_omp_target_enter_data (loc, parser, context);
}
else if (strcmp (p, "exit") == 0)
{
c_parser_consume_token (parser);
c_parser_omp_target_exit_data (loc, parser, context);
return false;
return c_parser_omp_target_exit_data (loc, parser, context);
}
else if (strcmp (p, "update") == 0)
{
@ -21599,7 +21598,7 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context)
OpenMP 5.0
#pragma omp declare variant (identifier) match (context-selector) */
static void
static bool
c_parser_omp_declare (c_parser *parser, enum pragma_context context)
{
c_parser_consume_pragma (parser);
@ -21611,37 +21610,38 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context)
/* c_parser_consume_token (parser); done in
c_parser_omp_declare_simd. */
c_parser_omp_declare_simd (parser, context);
return;
return true;
}
if (strcmp (p, "reduction") == 0)
{
c_parser_consume_token (parser);
c_parser_omp_declare_reduction (parser, context);
return;
return false;
}
if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser, false);
return;
return false;
}
if (strcmp (p, "target") == 0)
{
c_parser_consume_token (parser);
c_parser_omp_declare_target (parser);
return;
return false;
}
if (strcmp (p, "variant") == 0)
{
/* c_parser_consume_token (parser); done in
c_parser_omp_declare_simd. */
c_parser_omp_declare_simd (parser, context);
return;
return true;
}
}
c_parser_error (parser, "expected %<simd%>, %<reduction%>, "
"%<target%> or %<variant%>");
c_parser_skip_to_pragma_eol (parser);
return false;
}
/* OpenMP 5.0

View File

@ -42137,7 +42137,7 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok,
"%<depend%> clause may only be used in compound "
"statements");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return false;
return true;
}
tree clauses
= cp_parser_omp_all_clauses (parser,
@ -42661,7 +42661,7 @@ cp_parser_omp_cancel (cp_parser *parser, cp_token *pragma_tok)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SECTIONS) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASKGROUP))
static void
static bool
cp_parser_omp_cancellation_point (cp_parser *parser, cp_token *pragma_tok,
enum pragma_context context)
{
@ -42683,7 +42683,7 @@ cp_parser_omp_cancellation_point (cp_parser *parser, cp_token *pragma_tok,
{
cp_parser_error (parser, "expected %<point%>");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return;
return false;
}
if (context != pragma_compound)
@ -42695,7 +42695,7 @@ cp_parser_omp_cancellation_point (cp_parser *parser, cp_token *pragma_tok,
else
cp_parser_error (parser, "expected declaration specifiers");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return;
return true;
}
clauses = cp_parser_omp_all_clauses (parser,
@ -42703,6 +42703,7 @@ cp_parser_omp_cancellation_point (cp_parser *parser, cp_token *pragma_tok,
"#pragma omp cancellation point",
pragma_tok);
finish_omp_cancellation_point (clauses);
return true;
}
/* OpenMP 4.0:
@ -42998,7 +42999,7 @@ cp_parser_omp_target_data (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
static bool
cp_parser_omp_target_enter_data (cp_parser *parser, cp_token *pragma_tok,
enum pragma_context context)
{
@ -43018,7 +43019,7 @@ cp_parser_omp_target_enter_data (cp_parser *parser, cp_token *pragma_tok,
{
cp_parser_error (parser, "expected %<data%>");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
return false;
}
if (context == pragma_stmt)
@ -43027,7 +43028,7 @@ cp_parser_omp_target_enter_data (cp_parser *parser, cp_token *pragma_tok,
"%<#pragma %s%> may only be used in compound statements",
"omp target enter data");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
return true;
}
tree clauses
@ -43067,14 +43068,15 @@ cp_parser_omp_target_enter_data (cp_parser *parser, cp_token *pragma_tok,
error_at (pragma_tok->location,
"%<#pragma omp target enter data%> must contain at least "
"one %<map%> clause");
return NULL_TREE;
return true;
}
tree stmt = make_node (OMP_TARGET_ENTER_DATA);
TREE_TYPE (stmt) = void_type_node;
OMP_TARGET_ENTER_DATA_CLAUSES (stmt) = clauses;
SET_EXPR_LOCATION (stmt, pragma_tok->location);
return add_stmt (stmt);
add_stmt (stmt);
return true;
}
/* OpenMP 4.5:
@ -43088,7 +43090,7 @@ cp_parser_omp_target_enter_data (cp_parser *parser, cp_token *pragma_tok,
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
static bool
cp_parser_omp_target_exit_data (cp_parser *parser, cp_token *pragma_tok,
enum pragma_context context)
{
@ -43108,7 +43110,7 @@ cp_parser_omp_target_exit_data (cp_parser *parser, cp_token *pragma_tok,
{
cp_parser_error (parser, "expected %<data%>");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
return false;
}
if (context == pragma_stmt)
@ -43117,7 +43119,7 @@ cp_parser_omp_target_exit_data (cp_parser *parser, cp_token *pragma_tok,
"%<#pragma %s%> may only be used in compound statements",
"omp target exit data");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
return true;
}
tree clauses
@ -43159,14 +43161,15 @@ cp_parser_omp_target_exit_data (cp_parser *parser, cp_token *pragma_tok,
error_at (pragma_tok->location,
"%<#pragma omp target exit data%> must contain at least "
"one %<map%> clause");
return NULL_TREE;
return true;
}
tree stmt = make_node (OMP_TARGET_EXIT_DATA);
TREE_TYPE (stmt) = void_type_node;
OMP_TARGET_EXIT_DATA_CLAUSES (stmt) = clauses;
SET_EXPR_LOCATION (stmt, pragma_tok->location);
return add_stmt (stmt);
add_stmt (stmt);
return true;
}
/* OpenMP 4.0:
@ -43190,7 +43193,7 @@ cp_parser_omp_target_update (cp_parser *parser, cp_token *pragma_tok,
"%<#pragma %s%> may only be used in compound statements",
"omp target update");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return false;
return true;
}
tree clauses
@ -43202,7 +43205,7 @@ cp_parser_omp_target_update (cp_parser *parser, cp_token *pragma_tok,
error_at (pragma_tok->location,
"%<#pragma omp target update%> must contain at least one "
"%<from%> or %<to%> clauses");
return false;
return true;
}
tree stmt = make_node (OMP_TARGET_UPDATE);
@ -43210,7 +43213,7 @@ cp_parser_omp_target_update (cp_parser *parser, cp_token *pragma_tok,
OMP_TARGET_UPDATE_CLAUSES (stmt) = clauses;
SET_EXPR_LOCATION (stmt, pragma_tok->location);
add_stmt (stmt);
return false;
return true;
}
/* OpenMP 4.0:
@ -43364,14 +43367,12 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok,
else if (strcmp (p, "enter") == 0)
{
cp_lexer_consume_token (parser->lexer);
cp_parser_omp_target_enter_data (parser, pragma_tok, context);
return false;
return cp_parser_omp_target_enter_data (parser, pragma_tok, context);
}
else if (strcmp (p, "exit") == 0)
{
cp_lexer_consume_token (parser->lexer);
cp_parser_omp_target_exit_data (parser, pragma_tok, context);
return false;
return cp_parser_omp_target_exit_data (parser, pragma_tok, context);
}
else if (strcmp (p, "update") == 0)
{
@ -46432,7 +46433,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
cp_token *pragma_tok;
unsigned int id;
tree stmt;
bool ret;
bool ret = false;
pragma_tok = cp_lexer_consume_token (parser->lexer);
gcc_assert (pragma_tok->type == CPP_PRAGMA);
@ -46457,6 +46458,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
case pragma_stmt:
error_at (pragma_tok->location, "%<#pragma %s%> may only be "
"used in compound statements", "omp barrier");
ret = true;
break;
default:
goto bad_stmt;
@ -46472,6 +46474,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
case pragma_stmt:
error_at (pragma_tok->location, "%<#pragma %s%> may only be "
"used in compound statements", "omp depobj");
ret = true;
break;
default:
goto bad_stmt;
@ -46487,6 +46490,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
case pragma_stmt:
error_at (pragma_tok->location, "%<#pragma %s%> may only be "
"used in compound statements", "omp flush");
ret = true;
break;
default:
goto bad_stmt;
@ -46503,6 +46507,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"omp taskwait");
ret = true;
break;
default:
goto bad_stmt;
@ -46519,6 +46524,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"omp taskyield");
ret = true;
break;
default:
goto bad_stmt;
@ -46535,6 +46541,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"omp cancel");
ret = true;
break;
default:
goto bad_stmt;
@ -46542,8 +46549,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
break;
case PRAGMA_OMP_CANCELLATION_POINT:
cp_parser_omp_cancellation_point (parser, pragma_tok, context);
return false;
return cp_parser_omp_cancellation_point (parser, pragma_tok, context);
case PRAGMA_OMP_THREADPRIVATE:
cp_parser_omp_threadprivate (parser, pragma_tok);
@ -46562,6 +46568,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"acc enter data");
ret = true;
break;
}
else if (context != pragma_compound)
@ -46575,6 +46582,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"acc exit data");
ret = true;
break;
}
else if (context != pragma_compound)
@ -46587,6 +46595,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
{
error_at (pragma_tok->location,
"%<#pragma acc routine%> must be at file scope");
ret = true;
break;
}
cp_parser_oacc_routine (parser, pragma_tok, context);
@ -46598,6 +46607,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"acc update");
ret = true;
break;
}
else if (context != pragma_compound)
@ -46611,6 +46621,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma %s%> may only be used in compound statements",
"acc wait");
ret = true;
break;
}
else if (context != pragma_compound)
@ -46657,6 +46668,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
error_at (pragma_tok->location,
"%<#pragma omp requires%> may only be used at file or "
"namespace scope");
ret = true;
break;
}
return cp_parser_omp_requires (parser, pragma_tok);
@ -46769,7 +46781,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
}
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return false;
return ret;
}
/* The interface the pragma parsers have to the lexer. */

View File

@ -156,64 +156,64 @@ f4 (int x)
{
do
#pragma omp barrier /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
{
do
#pragma omp flush /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
{
do
#pragma omp taskwait /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
{
do
#pragma omp taskyield /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
#pragma omp parallel
{
do
#pragma omp cancel parallel /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
#pragma omp parallel
{
do
#pragma omp cancellation point parallel /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
#pragma omp for ordered(1)
for (i = 0; i < 16; i++)
{
{
do
#pragma omp ordered depend(source) /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
{
do
#pragma omp ordered depend(sink: i-1) /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
}
{
do
#pragma omp target enter data map(to:i) /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
{
do
#pragma omp target update to(i) /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
{
do
#pragma omp target exit data map(from:i) /* { dg-error "may only be used in compound statements" } */
while (0); /* { dg-error "before" "" { target c++ } } */
} /* { dg-error "before" "" { target c++ } } */
while (0);
}
}
void

View File

@ -11,8 +11,7 @@ foo ()
// { dg-error "#pragma omp section" "" { target *-*-* } .-1 }
// { dg-error "#pragma omp flush" "" { target *-*-* } .-2 }
[[omp::sequence (directive (flush), omp::directive (section))]]; // { dg-error "must be the only specified attribute on a statement" }
// { dg-error "#pragma omp section" "" { target *-*-* } .-1 }
// { dg-error "#pragma omp flush" "" { target *-*-* } .-2 }
// { dg-error "#pragma omp flush" "" { target *-*-* } .-1 }
[[gnu::cold, omp::directive (section)]]; // { dg-error "must be the only specified attribute on a statement" }
// { dg-error "#pragma omp section" "" { target *-*-* } .-1 }
[[omp::directive (section)]] [[gnu::cold]]; // { dg-error "must be the only specified attribute on a statement" }

View File

@ -9,4 +9,4 @@ void f3(bool p)
{
if (p)
#pragma omp barrier // { dg-error "compound statements" }
} // { dg-error "" }
}

View File

@ -16,8 +16,7 @@ void f1(void)
void f2(void)
{
label: /* { dg-error "label at end of compound statement" } */
/* { dg-warning "defined but not used" "" { target *-*-* } .-1 } */
label: /* { dg-warning "defined but not used" } */
#pragma omp barrier /* { dg-error "may only be used in compound statements" } */
}

View File

@ -15,7 +15,7 @@ f1 (int x)
lab:
#pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int))
extern int f5 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */
x++; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" "" { target *-*-* } .-1 } */
x++;
}
return x;
}

View File

@ -17,7 +17,7 @@ f1 (int x)
lab:
#pragma omp declare variant (fn0) match (user={condition(0)})
extern int f5 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */
x++; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" "" { target *-*-* } .-1 } */
x++;
}
return x;
}