From fce5e5e35fa397389079203760dd1880fa3edc41 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 9 Sep 2015 09:24:03 +0200 Subject: [PATCH] re PR c/67500 (OpenMP ICE with invalid safelen/simdlen/alignment expressions) PR c/67500 * c-parser.c (c_parser_omp_clause_aligned, c_parser_omp_clause_safelen, c_parser_omp_clause_simdlen): Fix up test for errors. * c-decl.c (temp_pop_parm_decls): Allow b->decl equal to error_mark_node. * gcc.dg/gomp/pr67500.c: New test. From-SVN: r227577 --- gcc/c/ChangeLog | 7 +++++ gcc/c/c-decl.c | 3 ++- gcc/c/c-parser.c | 18 ++++++------- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/gomp/pr67500.c | 42 +++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/pr67500.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index dadec059618..141be369b6d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,12 @@ 2015-09-09 Jakub Jelinek + PR c/67500 + * c-parser.c (c_parser_omp_clause_aligned, + c_parser_omp_clause_safelen, c_parser_omp_clause_simdlen): Fix up + test for errors. + * c-decl.c (temp_pop_parm_decls): Allow b->decl equal to + error_mark_node. + PR c/67495 * c-parser.c (c_parser_omp_atomic): Use c_parser_cast_expression instead of c_parser_unary_expression. If the result is !lvalue_p, diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index b83c584c701..5e5b6d7dfc2 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -8912,7 +8912,8 @@ temp_pop_parm_decls (void) current_scope->bindings = NULL; for (; b; b = free_binding_and_advance (b)) { - gcc_assert (TREE_CODE (b->decl) == PARM_DECL); + gcc_assert (TREE_CODE (b->decl) == PARM_DECL + || b->decl == error_mark_node); gcc_assert (I_SYMBOL_BINDING (b->id) == b); I_SYMBOL_BINDING (b->id) = b->shadowed; if (b->shadowed && b->shadowed->u.type) diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 86ccbe7730c..6213fd45237 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -11231,9 +11231,9 @@ c_parser_omp_clause_aligned (c_parser *parser, tree list) tree alignment = c_parser_expr_no_commas (parser, NULL).value; mark_exp_read (alignment); alignment = c_fully_fold (alignment, false, NULL); - if (!INTEGRAL_TYPE_P (TREE_TYPE (alignment)) - && TREE_CODE (alignment) != INTEGER_CST - && tree_int_cst_sgn (alignment) != 1) + if (TREE_CODE (alignment) != INTEGER_CST + || !INTEGRAL_TYPE_P (TREE_TYPE (alignment)) + || tree_int_cst_sgn (alignment) != 1) { error_at (clause_loc, "% clause alignment expression must " "be positive constant integer expression"); @@ -11310,9 +11310,9 @@ c_parser_omp_clause_safelen (c_parser *parser, tree list) t = c_parser_expr_no_commas (parser, NULL).value; mark_exp_read (t); t = c_fully_fold (t, false, NULL); - if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) - && TREE_CODE (t) != INTEGER_CST - && tree_int_cst_sgn (t) != 1) + if (TREE_CODE (t) != INTEGER_CST + || !INTEGRAL_TYPE_P (TREE_TYPE (t)) + || tree_int_cst_sgn (t) != 1) { error_at (clause_loc, "% clause expression must " "be positive constant integer expression"); @@ -11346,9 +11346,9 @@ c_parser_omp_clause_simdlen (c_parser *parser, tree list) t = c_parser_expr_no_commas (parser, NULL).value; mark_exp_read (t); t = c_fully_fold (t, false, NULL); - if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) - && TREE_CODE (t) != INTEGER_CST - && tree_int_cst_sgn (t) != 1) + if (TREE_CODE (t) != INTEGER_CST + || !INTEGRAL_TYPE_P (TREE_TYPE (t)) + || tree_int_cst_sgn (t) != 1) { error_at (clause_loc, "% clause expression must " "be positive constant integer expression"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4afb642ac93..c1c0b6c01da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-09-09 Jakub Jelinek + PR c/67500 + * gcc.dg/gomp/pr67500.c: New test. + PR c/67495 * gcc.dg/gomp/pr67495.c: New test. diff --git a/gcc/testsuite/gcc.dg/gomp/pr67500.c b/gcc/testsuite/gcc.dg/gomp/pr67500.c new file mode 100644 index 00000000000..13a6903d72d --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr67500.c @@ -0,0 +1,42 @@ +/* PR c/67500 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +#pragma omp declare simd simdlen(d) /* { dg-error "clause expression must be positive constant integer expression" } */ +void f1 (int); /* { dg-error "undeclared here" "" { target *-*-* } 5 } */ +#pragma omp declare simd simdlen(0.5) /* { dg-error "clause expression must be positive constant integer expression" } */ +void f2 (int); +#pragma omp declare simd simdlen(-2) /* { dg-error "clause expression must be positive constant integer expression" } */ +void f3 (int); +#pragma omp declare simd simdlen(0) /* { dg-error "clause expression must be positive constant integer expression" } */ +void f4 (int); + +void +foo (int *p) +{ + int i; + #pragma omp simd safelen(d) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) /* { dg-error "undeclared" "" { target *-*-* } 18 } */ + ; + #pragma omp simd safelen(0.5) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; + #pragma omp simd safelen(-2) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; + #pragma omp simd safelen(0) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; + #pragma omp simd aligned(p:d) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; + #pragma omp simd aligned(p:0.5) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; + #pragma omp simd aligned(p:-2) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; + #pragma omp simd aligned(p:0) /* { dg-error "must be positive constant integer expression" } */ + for (i = 0; i < 16; ++i) + ; +}