From: Tobias Burnus Date: Fri, 27 Mar 2015 20:21:52 +0000 (+0100) Subject: re PR c/65586 (-fopenmp-simd rejects valid input) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=62021f64e550290e77a8e56270617a0a4ba673da;p=gcc.git re PR c/65586 (-fopenmp-simd rejects valid input) 2015-03-27 Tobias Burnus 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 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ad5edcfbf48..f3b05c13e12 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2015-03-27 Tobias Burnus + + 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 * c-decl.c (c_decl_attributes): Also add "omp declare target" diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 5cc38923078..024dbd2af8a 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -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) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a3324fe306..a9f872dc5e1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2015-03-27 Tobias Burnus + + 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 PR c++/65556 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a18f38ce0af..4d6b479b497 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index de043af08ed..d94f5a12b53 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-27 Tobias Burnus + + 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 PR target/65248 diff --git a/gcc/testsuite/g++.dg/gomp/openmp-simd-3.C b/gcc/testsuite/g++.dg/gomp/openmp-simd-3.C new file mode 100644 index 00000000000..eba9de27d98 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/openmp-simd-3.C @@ -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" } } */ diff --git a/gcc/testsuite/gcc.dg/gomp/openmp-simd-3.c b/gcc/testsuite/gcc.dg/gomp/openmp-simd-3.c new file mode 100644 index 00000000000..eba9de27d98 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/openmp-simd-3.c @@ -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" } } */