[C++ gomp] Fix ICE on type dependent num_threads or schedule chunk size (PR c++/33372)
Jakub Jelinek
jakub@redhat.com
Mon Oct 22 05:42:00 GMT 2007
Hi!
The first testcase ICEs because t is IDENTIFIER_NODE without a type.
Although type_dependent_expression_p will return true and thus no error
is reported (during parsing of the template; it is reported during
instantiation), as INTEGRAL_TYPE_P (TREE_TYPE (t)) is tested first, we
still ICE dereferencing it.
Fixed by reordering the two tests. Regtested on x86_64-linux.
Ok for 4.2/trunk?
2007-10-21 Jakub Jelinek <jakub@redhat.com>
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.
--- gcc/cp/semantics.c.jj 2007-09-22 23:16:19.000000000 +0200
+++ gcc/cp/semantics.c 2007-10-22 04:38:45.000000000 +0200
@@ -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;
--- gcc/testsuite/g++.dg/gomp/pr33372-1.C.jj 2007-10-22 04:49:18.000000000 +0200
+++ gcc/testsuite/g++.dg/gomp/pr33372-1.C 2007-10-22 04:51:41.000000000 +0200
@@ -0,0 +1,19 @@
+// PR c++/33372
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+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<int> ();
+}
--- gcc/testsuite/g++.dg/gomp/pr33372-2.C.jj 2007-10-22 04:49:18.000000000 +0200
+++ gcc/testsuite/g++.dg/gomp/pr33372-2.C 2007-10-22 04:47:20.000000000 +0200
@@ -0,0 +1,19 @@
+// PR c++/33372
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+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<int> ();
+}
--- gcc/testsuite/g++.dg/gomp/pr33372-3.C.jj 2007-10-22 04:49:18.000000000 +0200
+++ gcc/testsuite/g++.dg/gomp/pr33372-3.C 2007-10-22 04:52:16.000000000 +0200
@@ -0,0 +1,19 @@
+// PR c++/33372
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+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<double> ();
+}
Jakub
More information about the Gcc-patches
mailing list