re PR c++/34607 (ICE with invalid for loop after #pragma omp for)

PR c++/34607
	* c-parser.c (c_parser_omp_for_loop): Don't call c_finish_omp_for
	if DECL_INITIAL (decl) is error_mark_node.

	* semantics.c (finish_omp_for): Don't call c_finish_omp_for
	if decl or init is error_mark_node.

	* gcc.dg/gomp/pr34607.c: New test.
	* g++.dg/gomp/pr34607.C: New test.

From-SVN: r131730
This commit is contained in:
Jakub Jelinek 2008-01-22 18:25:37 +01:00 committed by Jakub Jelinek
parent 270e749db4
commit 61c3a446a2
7 changed files with 54 additions and 3 deletions

View file

@ -1,5 +1,9 @@
2008-01-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34607
* c-parser.c (c_parser_omp_for_loop): Don't call c_finish_omp_for
if DECL_INITIAL (decl) is error_mark_node.
PR c++/34914
* c-common.c (handle_vector_size_attribute): Only allow
integral, scalar float and fixed point types. Handle OFFSET_TYPE

View file

@ -7547,6 +7547,8 @@ c_parser_omp_for_loop (c_parser *parser)
decl = check_for_loop_decls ();
if (decl == NULL)
goto error_init;
if (DECL_INITIAL (decl) == error_mark_node)
decl = error_mark_node;
init = decl;
}
else if (c_parser_next_token_is (parser, CPP_NAME)
@ -7597,7 +7599,7 @@ c_parser_omp_for_loop (c_parser *parser)
c_break_label = save_break;
c_cont_label = save_cont;
/* Only bother calling c_finish_omp_for if we havn't already generated
/* Only bother calling c_finish_omp_for if we haven't already generated
an error from the initialization parsing. */
if (decl != NULL && decl != error_mark_node && init != error_mark_node)
return c_finish_omp_for (loc, decl, init, cond, incr, body, NULL);

View file

@ -1,5 +1,9 @@
2008-01-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34607
* semantics.c (finish_omp_for): Don't call c_finish_omp_for
if decl or init is error_mark_node.
PR c++/34918
* error.c (dump_expr): Handle VECTOR_CST.

View file

@ -3827,7 +3827,7 @@ tree
finish_omp_for (location_t locus, tree decl, tree init, tree cond,
tree incr, tree body, tree pre_body)
{
tree omp_for;
tree omp_for = NULL;
if (decl == NULL)
{
@ -3919,7 +3919,8 @@ finish_omp_for (location_t locus, tree decl, tree init, tree cond,
TREE_OPERAND (cond, n)
= fold_build_cleanup_point_expr (TREE_TYPE (t), t);
}
omp_for = c_finish_omp_for (locus, decl, init, cond, incr, body, pre_body);
if (decl != error_mark_node && init != error_mark_node)
omp_for = c_finish_omp_for (locus, decl, init, cond, incr, body, pre_body);
if (omp_for != NULL
&& TREE_CODE (OMP_FOR_INCR (omp_for)) == MODIFY_EXPR
&& TREE_SIDE_EFFECTS (TREE_OPERAND (OMP_FOR_INCR (omp_for), 1))

View file

@ -1,5 +1,9 @@
2008-01-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34607
* gcc.dg/gomp/pr34607.c: New test.
* g++.dg/gomp/pr34607.C: New test.
PR c++/34914
* g++.dg/ext/vector10.C: New test.

View file

@ -0,0 +1,18 @@
// PR c++/34607
// { dg-do compile }
// { dg-options "-fopenmp" }
void
foo ()
{
#pragma omp for
for (int i =; i < 2; ++i) // { dg-error "expected primary-expression" }
;
#pragma omp for
for (T i = 54; i < 56; i++) // { dg-error "was not declared|expected" }
;
T j; // { dg-error "was not declared|expected" }
#pragma omp for
for (j = 1; j < 3; j++) // { dg-error "was not declared" }
; // { dg-error "expected" }
}

View file

@ -0,0 +1,18 @@
/* PR c++/34607 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -std=gnu99" } */
void
foo ()
{
#pragma omp for
for (int i =; i < 2; ++i) /* { dg-error "expected expression before" } */
;
#pragma omp for
for (T i = 54; i < 56; i++) /* { dg-error "expected iteration declaration" } */
;
T j; /* { dg-error "undeclared|for each function|expected" } */
#pragma omp for
for (j = 1; j < 3; j++) /* { dg-error "undeclared" } */
;
}