This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix #pragma omp {target,ordered} error-recovery (PR c++/79429)


Hi!

This patch fixes error-recovery on the following testcases.
{push,pop}_omp_privatization_clauses should not be used outside of
functions, fixed by diagnosing it/punting it before we call those.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2017-02-09  Jakub Jelinek  <jakub@redhat.com>

	PR c++/79429
	* parser.c (cp_parser_omp_ordered): Don't check for non-pragma_stmt
	non-pragma_compound context here.
	(cp_parser_omp_target): Likewise.
	(cp_parser_pragma): Don't call push_omp_privatization_clauses and
	parsing for ordered and target omp pragmas in non-pragma_stmt
	non-pragma_compound contexts.

	* c-c++-common/gomp/pr79429.c: New test.
	* g++.dg/gomp/pr79429.C: New test.

--- gcc/cp/parser.c.jj	2017-02-09 10:07:38.000000000 +0100
+++ gcc/cp/parser.c	2017-02-09 10:53:54.649952780 +0100
@@ -34923,13 +34923,6 @@ cp_parser_omp_ordered (cp_parser *parser
 {
   location_t loc = pragma_tok->location;
 
-  if (context != pragma_stmt && context != pragma_compound)
-    {
-      cp_parser_error (parser, "expected declaration specifiers");
-      cp_parser_skip_to_pragma_eol (parser, pragma_tok);
-      return false;
-    }
-
   if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
     {
       tree id = cp_lexer_peek_token (parser->lexer)->u.value;
@@ -35835,13 +35828,6 @@ cp_parser_omp_target (cp_parser *parser,
 {
   tree *pc = NULL, stmt;
 
-  if (context != pragma_stmt && context != pragma_compound)
-    {
-      cp_parser_error (parser, "expected declaration specifiers");
-      cp_parser_skip_to_pragma_eol (parser, pragma_tok);
-      return false;
-    }
-
   if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
     {
       tree id = cp_lexer_peek_token (parser->lexer)->u.value;
@@ -38272,12 +38258,16 @@ cp_parser_pragma (cp_parser *parser, enu
       return true;
 
     case PRAGMA_OMP_ORDERED:
+      if (context != pragma_stmt && context != pragma_compound)
+	goto bad_stmt;
       stmt = push_omp_privatization_clauses (false);
       ret = cp_parser_omp_ordered (parser, pragma_tok, context, if_p);
       pop_omp_privatization_clauses (stmt);
       return ret;
 
     case PRAGMA_OMP_TARGET:
+      if (context != pragma_stmt && context != pragma_compound)
+	goto bad_stmt;
       stmt = push_omp_privatization_clauses (false);
       ret = cp_parser_omp_target (parser, pragma_tok, context, if_p);
       pop_omp_privatization_clauses (stmt);
--- gcc/testsuite/c-c++-common/gomp/pr79429.c.jj	2017-02-09 10:57:01.071495848 +0100
+++ gcc/testsuite/c-c++-common/gomp/pr79429.c	2017-02-09 10:56:22.000000000 +0100
@@ -0,0 +1,3 @@
+/* PR c++/79429 */
+
+#pragma omp target /* { dg-error "expected declaration specifiers" } */
--- gcc/testsuite/g++.dg/gomp/pr79429.C.jj	2017-02-09 10:57:22.552212847 +0100
+++ gcc/testsuite/g++.dg/gomp/pr79429.C	2017-02-09 10:57:32.363083593 +0100
@@ -0,0 +1,3 @@
+// PR c++/79429
+
+#pragma omp ordered // { dg-error "expected declaration specifiers" }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]