re PR c/65586 (-fopenmp-simd rejects valid input)

2015-03-27  Tobias Burnus  <burnus@net-b.de>

        PR c/65586
gcc/c/
        * c-parser.c (c_parser_skip_to_pragma_eol): Optionally, don't
        error out.
        (c_parser_omp_for, c_parser_omp_parallel, c_parser_omp_distribute,
        c_parser_omp_teams, c_parser_omp_target, c_parser_omp_declare):
        Update calls to not error for skipped omp pragmas with -fopenmp-simd.

gcc/cp/
        * parser.c (cp_parser_omp_for, cp_parser_omp_parallel,
        cp_parser_omp_distribute, cp_parser_omp_teams, cp_parser_omp_target,
        cp_parser_omp_declare): Don't show error for skipped omp pragmas
        with -fopenmp-simd.

gcc/testsuite/
        * g++.dg/gomp/openmp-simd-3.C: New.
        * gcc.dg/gomp/openmp-simd-3.c: New.

From-SVN: r221744
This commit is contained in:
Tobias Burnus 2015-03-27 21:21:52 +01:00 committed by Tobias Burnus
parent a5eef8e9b0
commit 62021f64e5
7 changed files with 79 additions and 26 deletions

View File

@ -1,3 +1,12 @@
2015-03-27 Tobias Burnus <burnus@net-b.de>
PR c/65586
* c-parser.c (c_parser_skip_to_pragma_eol): Optionally, don't
error out.
(c_parser_omp_for, c_parser_omp_parallel, c_parser_omp_distribute,
c_parser_omp_teams, c_parser_omp_target, c_parser_omp_declare):
Update calls to not error for skipped omp pragmas with -fopenmp-simd.
2015-03-19 Jakub Jelinek <jakub@redhat.com>
* c-decl.c (c_decl_attributes): Also add "omp declare target"

View File

@ -991,24 +991,24 @@ c_parser_skip_to_end_of_parameter (c_parser *parser)
end of line marker. */
static void
c_parser_skip_to_pragma_eol (c_parser *parser)
c_parser_skip_to_pragma_eol (c_parser *parser, bool error_if_not_eol = true)
{
gcc_assert (parser->in_pragma);
parser->in_pragma = false;
if (!c_parser_require (parser, CPP_PRAGMA_EOL, "expected end of line"))
while (true)
{
c_token *token = c_parser_peek_token (parser);
if (token->type == CPP_EOF)
break;
if (token->type == CPP_PRAGMA_EOL)
{
c_parser_consume_token (parser);
break;
}
c_parser_consume_token (parser);
}
if (error_if_not_eol && c_parser_peek_token (parser)->type != CPP_PRAGMA_EOL)
c_parser_error (parser, "expected end of line");
cpp_ttype token_type;
do
{
c_token *token = c_parser_peek_token (parser);
token_type = token->type;
if (token_type == CPP_EOF)
break;
c_parser_consume_token (parser);
}
while (token_type != CPP_PRAGMA_EOL);
parser->error = false;
}
@ -13223,7 +13223,7 @@ c_parser_omp_for (location_t loc, c_parser *parser,
}
if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser);
c_parser_skip_to_pragma_eol (parser, false);
return NULL_TREE;
}
@ -13448,7 +13448,7 @@ c_parser_omp_parallel (location_t loc, c_parser *parser,
}
else if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser);
c_parser_skip_to_pragma_eol (parser, false);
return NULL_TREE;
}
else if (c_parser_next_token_is (parser, CPP_NAME))
@ -13708,7 +13708,7 @@ c_parser_omp_distribute (location_t loc, c_parser *parser,
}
if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser);
c_parser_skip_to_pragma_eol (parser, false);
return NULL_TREE;
}
@ -13776,7 +13776,7 @@ c_parser_omp_teams (location_t loc, c_parser *parser,
}
if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser);
c_parser_skip_to_pragma_eol (parser, false);
return NULL_TREE;
}
@ -13921,7 +13921,7 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context)
}
else if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser);
c_parser_skip_to_pragma_eol (parser, false);
return false;
}
else if (strcmp (p, "data") == 0)
@ -14604,7 +14604,7 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context)
}
if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser);
c_parser_skip_to_pragma_eol (parser, false);
return;
}
if (strcmp (p, "target") == 0)

View File

@ -1,3 +1,11 @@
2015-03-27 Tobias Burnus <burnus@net-b.de>
PR c/65586
* parser.c (cp_parser_omp_for, cp_parser_omp_parallel,
cp_parser_omp_distribute, cp_parser_omp_teams, cp_parser_omp_target,
cp_parser_omp_declare): Don't show error for skipped omp pragmas with
-fopenmp-simd.
2015-03-27 Marek Polacek <polacek@redhat.com>
PR c++/65556

View File

@ -30768,7 +30768,7 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok,
}
if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_require_pragma_eol (parser, pragma_tok);
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
}
@ -30979,7 +30979,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok,
}
else if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_require_pragma_eol (parser, pragma_tok);
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
}
else if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
@ -31242,7 +31242,7 @@ cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok,
}
if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_require_pragma_eol (parser, pragma_tok);
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
}
@ -31321,7 +31321,7 @@ cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok,
}
if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_require_pragma_eol (parser, pragma_tok);
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
}
@ -31466,7 +31466,7 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok,
}
else if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_require_pragma_eol (parser, pragma_tok);
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return false;
}
else if (strcmp (p, "data") == 0)
@ -32442,7 +32442,7 @@ cp_parser_omp_declare (cp_parser *parser, cp_token *pragma_tok,
}
if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_require_pragma_eol (parser, pragma_tok);
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return;
}
if (strcmp (p, "target") == 0)

View File

@ -1,3 +1,9 @@
2015-03-27 Tobias Burnus <burnus@net-b.de>
PR c/65586
* g++.dg/gomp/openmp-simd-3.C: New.
* gcc.dg/gomp/openmp-simd-3.c: New.
2015-03-27 H.J. Lu <hongjiu.lu@intel.com>
PR target/65248

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-fopenmp-simd -fdump-tree-original" } */
/* PR c/65586 */
void foo() { }
int main() {
#pragma omp for collapse(1)
for (int i = 1; i <= 151; i+=31)
foo();
}
/* { dg-final { scan-tree-dump-not "omp" "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-fopenmp-simd -fdump-tree-original" } */
/* PR c/65586 */
void foo() { }
int main() {
#pragma omp for collapse(1)
for (int i = 1; i <= 151; i+=31)
foo();
}
/* { dg-final { scan-tree-dump-not "omp" "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */