From 5259c813103b272f141eb5aafc5e473301d58760 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 19 Dec 2007 13:58:32 +0100 Subject: [PATCH] re PR c++/34513 (static variable not found for C++ OpenMP) PR c++/34513 * parser.c (cp_parser_omp_parallel): For non-combined parallel call cp_parser_statement rather than cp_parser_already_scoped_statement. * testsuite/libgomp.c/pr34513.c: New test. * testsuite/libgomp.c++/pr34513.C: New test. From-SVN: r131059 --- gcc/cp/ChangeLog | 7 ++++++ gcc/cp/parser.c | 2 +- libgomp/ChangeLog | 6 +++++ libgomp/testsuite/libgomp.c++/pr34513.C | 32 ++++++++++++++++++++++++ libgomp/testsuite/libgomp.c/pr34513.c | 33 +++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 libgomp/testsuite/libgomp.c++/pr34513.C create mode 100644 libgomp/testsuite/libgomp.c/pr34513.c diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c7f0fc488ca..39eb736c5b3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2007-12-19 Jakub Jelinek + + PR c++/34513 + * parser.c (cp_parser_omp_parallel): For non-combined parallel + call cp_parser_statement rather than + cp_parser_already_scoped_statement. + 2007-12-18 Jason Merrill PR c++/34206 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f3d4ce207e6..d5926200108 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -20271,7 +20271,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok) switch (p_kind) { case PRAGMA_OMP_PARALLEL: - cp_parser_already_scoped_statement (parser); + cp_parser_statement (parser, NULL_TREE, false, NULL); par_clause = clauses; break; diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 49b6c549477..0ef0abf7386 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,9 @@ +2007-12-19 Jakub Jelinek + + PR c++/34513 + * testsuite/libgomp.c/pr34513.c: New test. + * testsuite/libgomp.c++/pr34513.C: New test. + 2007-12-17 Jack Howarth PR target/32765 diff --git a/libgomp/testsuite/libgomp.c++/pr34513.C b/libgomp/testsuite/libgomp.c++/pr34513.C new file mode 100644 index 00000000000..e5ad3bcb44d --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr34513.C @@ -0,0 +1,32 @@ +// PR c++/34513 +// { dg-do run } + +#include + +extern "C" void abort (); + +static int errors = 0; +static int thrs = 4; + +int +main () +{ + omp_set_dynamic (0); + + #pragma omp parallel num_threads (thrs) + { + static int shrd = 0; + + #pragma omp atomic + shrd += 1; + + #pragma omp barrier + + if (shrd != thrs) + #pragma omp atomic + errors += 1; + } + + if (errors) + abort (); +} diff --git a/libgomp/testsuite/libgomp.c/pr34513.c b/libgomp/testsuite/libgomp.c/pr34513.c new file mode 100644 index 00000000000..76c7ac1f3a5 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr34513.c @@ -0,0 +1,33 @@ +/* PR c++/34513 */ +/* { dg-do run } */ + +#include + +extern void abort (); + +static int errors = 0; +static int thrs = 4; + +int +main () +{ + omp_set_dynamic (0); + + #pragma omp parallel num_threads (thrs) + { + static int shrd = 0; + + #pragma omp atomic + shrd += 1; + + #pragma omp barrier + + if (shrd != thrs) + #pragma omp atomic + errors += 1; + } + + if (errors) + abort (); + return 0; +}