re PR c++/41967 (gcc get into endless loop when compiling an openmp program)

PR c++/41967
	* parser.c (cp_parser_omp_for_loop): After diagnosing not perfectly
	nested loop and parsing statements, don't cp_parser_require }, instead
	exit the loop if next token is CPP_EOF.

	* g++.dg/gomp/pr41967.C: New test.

From-SVN: r153972
This commit is contained in:
Jakub Jelinek 2009-11-06 18:51:20 +01:00 committed by Jakub Jelinek
parent 79af7c1f6d
commit 2e3135726b
4 changed files with 31 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2009-11-06 Jakub Jelinek <jakub@redhat.com>
PR c++/41967
* parser.c (cp_parser_omp_for_loop): After diagnosing not perfectly
nested loop and parsing statements, don't cp_parser_require }, instead
exit the loop if next token is CPP_EOF.
2009-11-05 Jason Merrill <jason@redhat.com>
PR c++/34180

View File

@ -22424,7 +22424,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
}
collapse_err = true;
cp_parser_statement_seq_opt (parser, NULL);
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>");
if (cp_lexer_next_token_is (parser->lexer, CPP_EOF))
break;
}
}

View File

@ -1,3 +1,8 @@
2009-11-06 Jakub Jelinek <jakub@redhat.com>
PR c++/41967
* g++.dg/gomp/pr41967.C: New test.
2009-11-06 Michael Matz <matz@suse.de>
PR middle-end/41963

View File

@ -0,0 +1,17 @@
// PR c++/41967
// { dg-do compile }
// { dg-options "-fopenmp" }
int
foo ()
{
int sum = 0;
#pragma omp for collapse(2)
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < 5; ++j)
++sum;
++sum; // { dg-error "collapsed loops not perfectly nested" }
}
return sum;
}