Hi,

in this regression we ICE during error recovery after an additional redundant error message. I think it's one of those cases (we have got quite a few elsewhere, in semantics.c too) when it's better to immediately return error_mark_node when mark_used returns false, even if we aren't in a SFINAE context. To be sure, I double checked that in those cases mark_used certainly issues an error, thus we aren't risking creating accepts-invalid bugs, it's only matter of fine tuning error recovery. Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////////
/cp
2016-04-14  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/70540
        * semantics.c (process_outer_var_ref): Unconditionally return
        error_mark_node when mark_used returns false.

/testsuite
2016-04-14  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/70540
        * g++.dg/cpp0x/auto47.C: New.

Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 234970)
+++ cp/semantics.c      (working copy)
@@ -3276,7 +3276,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t c
   tree initializer = convert_from_reference (decl);
 
   /* Mark it as used now even if the use is ill-formed.  */
-  if (!mark_used (decl, complain) && !(complain & tf_error))
+  if (!mark_used (decl, complain))
     return error_mark_node;
 
   bool saw_generic_lambda = false;
Index: testsuite/g++.dg/cpp0x/auto47.C
===================================================================
--- testsuite/g++.dg/cpp0x/auto47.C     (revision 0)
+++ testsuite/g++.dg/cpp0x/auto47.C     (working copy)
@@ -0,0 +1,8 @@
+// PR c++/70540
+// { dg-do compile { target c++11 } }
+
+void
+foo ()
+{
+  auto f = [&] { return f; };  // { dg-error "before deduction" }
+}

Reply via email to