From 6e684eee8d03ef8f75e864d355695b7097c38a9f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 22 Oct 2007 21:11:36 +0200 Subject: [PATCH] re PR c++/33372 (segfault on incomplete code in openmp mode) PR c++/33372 * semantics.c (finish_omp_clauses): Check !type_dependent_expression_p before checking if its type is integral. * g++.dg/gomp/pr33372-1.C: New test. * g++.dg/gomp/pr33372-2.C: New test. * g++.dg/gomp/pr33372-3.C: New test. From-SVN: r129555 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 8 ++++---- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/g++.dg/gomp/pr33372-1.C | 19 +++++++++++++++++++ gcc/testsuite/g++.dg/gomp/pr33372-2.C | 19 +++++++++++++++++++ gcc/testsuite/g++.dg/gomp/pr33372-3.C | 19 +++++++++++++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr33372-1.C create mode 100644 gcc/testsuite/g++.dg/gomp/pr33372-2.C create mode 100644 gcc/testsuite/g++.dg/gomp/pr33372-3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 903db53a323..29e5cb59882 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-10-22 Jakub Jelinek + + PR c++/33372 + * semantics.c (finish_omp_clauses): Check !type_dependent_expression_p + before checking if its type is integral. + 2007-10-22 Jason Merrill PR c++/33620 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b770269100d..815390c7671 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3413,8 +3413,8 @@ finish_omp_clauses (tree clauses) t = OMP_CLAUSE_NUM_THREADS_EXPR (c); if (t == error_mark_node) remove = true; - else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) - && !type_dependent_expression_p (t)) + else if (!type_dependent_expression_p (t) + && !INTEGRAL_TYPE_P (TREE_TYPE (t))) { error ("num_threads expression must be integral"); remove = true; @@ -3427,8 +3427,8 @@ finish_omp_clauses (tree clauses) ; else if (t == error_mark_node) remove = true; - else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) - && !type_dependent_expression_p (t)) + else if (!type_dependent_expression_p (t) + && !INTEGRAL_TYPE_P (TREE_TYPE (t))) { error ("schedule chunk size expression must be integral"); remove = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c49cd312383..e7308e905c1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-10-22 Jakub Jelinek + + PR c++/33372 + * g++.dg/gomp/pr33372-1.C: New test. + * g++.dg/gomp/pr33372-2.C: New test. + * g++.dg/gomp/pr33372-3.C: New test. + 2007-10-22 Michael Matz PR tree-optimization/33855 diff --git a/gcc/testsuite/g++.dg/gomp/pr33372-1.C b/gcc/testsuite/g++.dg/gomp/pr33372-1.C new file mode 100644 index 00000000000..62900bf65d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33372-1.C @@ -0,0 +1,19 @@ +// PR c++/33372 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +void f () +{ + extern T n (); +#pragma omp parallel num_threads(n) // { dg-error "num_threads expression must be integral" } + ; +#pragma omp parallel for schedule(static, n) + for (int i = 0; i < 10; i++) // { dg-error "chunk size expression must be integral" } + ; +} + +void g () +{ + f (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33372-2.C b/gcc/testsuite/g++.dg/gomp/pr33372-2.C new file mode 100644 index 00000000000..cce7ecc743c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33372-2.C @@ -0,0 +1,19 @@ +// PR c++/33372 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +void f () +{ + T n = 6; +#pragma omp parallel num_threads(n) + ; +#pragma omp parallel for schedule(static, n) + for (int i = 0; i < 10; i++) + ; +} + +void g () +{ + f (); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr33372-3.C b/gcc/testsuite/g++.dg/gomp/pr33372-3.C new file mode 100644 index 00000000000..8220f3c5ab8 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr33372-3.C @@ -0,0 +1,19 @@ +// PR c++/33372 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +void f () +{ + T n = 6; +#pragma omp parallel num_threads(n) // { dg-error "num_threads expression must be integral" } + ; +#pragma omp parallel for schedule(static, n) + for (int i = 0; i < 10; i++) // { dg-error "chunk size expression must be integral" } + ; +} + +void g () +{ + f (); +}