This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix tsubst_omp_for_iterator (PR c++/38639)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 27 Dec 2008 16:26:24 +0100
- Subject: [committed] Fix tsubst_omp_for_iterator (PR c++/38639)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
As shown e.g. on the attached testcase, calling tsubst_expr just on the type
was a bad idea. Fixed thusly, committed to trunk.
2008-12-27 Jakub Jelinek <jakub@redhat.com>
PR c++/38639
* pt.c (tsubst_omp_for_iterator): RECUR on whole init_expr instead of
just its type.
* g++.dg/gomp/pr38639.C: New test.
--- gcc/cp/pt.c.jj 2008-12-04 14:06:52.000000000 +0100
+++ gcc/cp/pt.c 2008-12-27 12:54:20.000000000 +0100
@@ -10334,14 +10334,11 @@ tsubst_omp_for_iterator (tree t, int i,
if (auto_node && init)
{
tree init_expr = init;
- tree orig_type;
if (TREE_CODE (init_expr) == DECL_EXPR)
init_expr = DECL_INITIAL (DECL_EXPR_DECL (init_expr));
- orig_type = TREE_TYPE (init_expr);
- TREE_TYPE (init_expr) = RECUR (TREE_TYPE (init_expr));
+ init_expr = RECUR (init_expr);
TREE_TYPE (decl)
= do_auto_deduction (TREE_TYPE (decl), init_expr, auto_node);
- TREE_TYPE (init_expr) = orig_type;
}
gcc_assert (!type_dependent_expression_p (decl));
--- gcc/testsuite/g++.dg/gomp/pr38639.C.jj 2008-12-27 12:51:57.000000000 +0100
+++ gcc/testsuite/g++.dg/gomp/pr38639.C 2008-12-27 12:51:38.000000000 +0100
@@ -0,0 +1,17 @@
+// PR c++/38639
+// { dg-do compile }
+// { dg-options "-fopenmp -std=c++0x" }
+
+template<int> void
+foo ()
+{
+#pragma omp parallel for
+ for (auto i = i = 0; i<4; ++i) // { dg-error "incomplete|unable|invalid" }
+ ;
+}
+
+void
+bar ()
+{
+ foo<0> (); // { dg-message "instantiated from here" }
+}
Jakub