Hi!

Is there a reason why we don't return error_mark_node no matter what
complain contains?
At least on the testcase if we don't return error_mark_node for
the uses of var before deduction of auto, then we ICE later on in some
assertion that expects sane types on the variables.  On the other testcase
it avoids a cascading of further errors, emits just the single error.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

What about all the other spots in pt.c that return error_mark_node
if mark_used failed only if complain doesn't have tf_error set?

2016-11-23  Jakub Jelinek  <ja...@redhat.com>

        PR c++/71450
        * pt.c (tsubst_copy): Return error_mark_node when mark_used
        fails, even when complain & tf_error.

        * g++.dg/cpp0x/pr71450-1.C: New test.
        * g++.dg/cpp0x/pr71450-2.C: New test.

--- gcc/cp/pt.c.jj      2016-11-18 20:04:26.000000000 +0100
+++ gcc/cp/pt.c 2016-11-23 11:04:11.073223790 +0100
@@ -14297,7 +14297,7 @@ tsubst_copy (tree t, tree args, tsubst_f
        }
       else
        r = t;
-      if (!mark_used (r, complain) && !(complain & tf_error))
+      if (!mark_used (r, complain))
        return error_mark_node;
       return r;
 
--- gcc/testsuite/g++.dg/cpp0x/pr71450-1.C.jj   2016-11-23 11:05:08.128508285 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/pr71450-1.C      2016-11-23 11:04:39.000000000 
+0100
@@ -0,0 +1,16 @@
+// PR c++/71450
+// { dg-do compile { target c++11 } }
+
+struct A { A operator+ (A a) { return a; } };
+
+template <class T>
+void foo (T t)
+{ 
+  auto x = t + x;      // { dg-error "use of 'x' before deduction of 'auto'" }
+}
+
+int
+main ()
+{ 
+  foo (A ());
+}
--- gcc/testsuite/g++.dg/cpp0x/pr71450-2.C.jj   2016-11-23 11:05:11.595464808 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/pr71450-2.C      2016-11-23 11:04:48.000000000 
+0100
@@ -0,0 +1,14 @@
+// PR c++/71450
+// { dg-do compile { target c++11 } }
+
+template <class T>
+void foo (T t)
+{ 
+  auto x = t + x;      // { dg-error "use of 'x' before deduction of 'auto'" }
+}
+
+int
+main ()
+{ 
+  foo (1);
+}

        Jakub

Reply via email to