From: Jakub Jelinek Date: Thu, 9 Feb 2017 14:06:58 +0000 (+0100) Subject: re PR c++/79429 (ICE in add_stmt, at cp/semantics.c:385) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f08683a154522492e2fdc9e970b145cd37f242de;p=gcc.git re PR c++/79429 (ICE in add_stmt, at cp/semantics.c:385) 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. From-SVN: r245303 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a71cca1d20b..6639fbdab9e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 2017-02-09 Jakub Jelinek + 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. + PR c/79431 * parser.c (cp_parser_oacc_declare): Formatting fix. (cp_parser_omp_declare_target): Don't invoke symtab_node::get on diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b46ee7c9454..aadf44d0a60 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -34934,13 +34934,6 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, { 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; @@ -35846,13 +35839,6 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, { 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; @@ -38283,12 +38269,16 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 18a7a08d2c8..8a64e729df7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2017-02-09 Jakub Jelinek + PR c++/79429 + * c-c++-common/gomp/pr79429.c: New test. + * g++.dg/gomp/pr79429.C: New test. + PR c/79431 * c-c++-common/gomp/pr79431.c: New test. diff --git a/gcc/testsuite/c-c++-common/gomp/pr79429.c b/gcc/testsuite/c-c++-common/gomp/pr79429.c new file mode 100644 index 00000000000..c9a54d5e08d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr79429.c @@ -0,0 +1,3 @@ +/* PR c++/79429 */ + +#pragma omp target /* { dg-error "expected declaration specifiers" } */ diff --git a/gcc/testsuite/g++.dg/gomp/pr79429.C b/gcc/testsuite/g++.dg/gomp/pr79429.C new file mode 100644 index 00000000000..8ecbcd38963 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr79429.C @@ -0,0 +1,3 @@ +// PR c++/79429 + +#pragma omp ordered // { dg-error "expected declaration specifiers" }