A rather simple fix for an ICE on invalid bug (low-priority 4.8/4.9 regression).

Bootstrapped and regtested without new failure on x86-64-gnu-linux.
OK for the trunk and 4.8?

Tobias
2013-06-12  Tobias Burnus  <bur...@net-b.de>

	PR c++/58567
	* pt.c (tsubst_omp_for_iterator): Early return for error_mark_node.

2013-06-12  Tobias Burnus  <bur...@net-b.de>

	PR c++/58567
	* g++.dg/gomp/pr58567.C: New.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 25d940c..ddc7112 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13035,6 +13035,10 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv,
   init_decl = (init && TREE_CODE (init) == DECL_EXPR);
   init = RECUR (init);
   decl = RECUR (decl);
+
+  if (decl == error_mark_node)
+    return;
+
   if (init_decl)
     {
       gcc_assert (!processing_template_decl);
diff --git a/gcc/testsuite/g++.dg/gomp/pr58567.C b/gcc/testsuite/g++.dg/gomp/pr58567.C
new file mode 100644
index 0000000..35a5bb0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr58567.C
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+/* PR c++/58567 - was ICEing before */
+
+template<typename T> void foo()
+{
+  #pragma omp parallel for
+  for (typename T::X i = 0; i < 100; ++i)  /* { dg-error "'int' is not a class, struct, or union type|expected iteration declaration or initialization" } */
+    ;
+}
+
+void bar()
+{
+  foo<int>();
+}

Reply via email to