aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-09-09 09:24:03 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2015-09-09 09:24:03 +0200
commitfce5e5e35fa397389079203760dd1880fa3edc41 (patch)
treece2a1fe9ee949f1a0961fb1e5c6df3ceead751c4
parentf4b189d53bbc5def47c17cdc04c1c7fd291f29b1 (diff)
downloadgcc-fce5e5e35fa397389079203760dd1880fa3edc41.zip
gcc-fce5e5e35fa397389079203760dd1880fa3edc41.tar.gz
gcc-fce5e5e35fa397389079203760dd1880fa3edc41.tar.bz2
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
-rw-r--r--gcc/c/ChangeLog7
-rw-r--r--gcc/c/c-decl.c3
-rw-r--r--gcc/c/c-parser.c18
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr67500.c42
5 files changed, 63 insertions, 10 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index dadec05..141be36 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,12 @@
2015-09-09 Jakub Jelinek <jakub@redhat.com>
+ 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 b83c584..5e5b6d7 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 86ccbe7..6213fd4 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, "%<aligned%> 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, "%<safelen%> 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, "%<simdlen%> clause expression must "
"be positive constant integer expression");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4afb642..c1c0b6c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2015-09-09 Jakub Jelinek <jakub@redhat.com>
+ 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 0000000..13a6903
--- /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)
+ ;
+}