]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38639 (ICE with invalid use of auto in parallel for-loop)
authorJakub Jelinek <jakub@redhat.com>
Sat, 27 Dec 2008 15:24:52 +0000 (16:24 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 27 Dec 2008 15:24:52 +0000 (16:24 +0100)
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.

From-SVN: r142933

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr38639.C [new file with mode: 0644]

index 94e1a7cd2c10f7afec1f881c3c7c56f059c490dc..2771f7e85baa6ab869dede3404bc6934c675d7a4 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2008-12-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/38597
index db81942eb00e7df890e27fd074a9a5bef4173832..786e8456b99355d8ca35ccb459d1ae48b38c3f6a 100644 (file)
@@ -10334,14 +10334,11 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
   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));
 
index 4afbc8cc5bfdc74784b30823c68fa2271cd9b0bc..fb334fb25595cbd0b620d30fb6878eb1952f4cd3 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/38639
+       * g++.dg/gomp/pr38639.C: New test.
+
 2008-12-23  Andrew Pinski  <pinskia@gmail.com>
 
        PR middle-end/38590
diff --git a/gcc/testsuite/g++.dg/gomp/pr38639.C b/gcc/testsuite/g++.dg/gomp/pr38639.C
new file mode 100644 (file)
index 0000000..1da3cec
--- /dev/null
@@ -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" }
+}