diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8efaa80b344..5a9ad978d83 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-04-21 Paolo Carlini + + PR c++/70540 + * semantics.c (process_outer_var_ref): Unconditionally return + error_mark_node when mark_used returns false. + 2016-04-21 Marek Polacek PR c++/70513 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 93b39ac9a77..2365a732cbe 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3281,7 +3281,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain) 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 52257e5bd8a..0227f70243b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-21 Paolo Carlini + + PR c++/70540 + * g++.dg/cpp0x/auto48.C: New. + 2016-04-21 Marek Polacek PR c++/70513 diff --git a/gcc/testsuite/g++.dg/cpp0x/auto48.C b/gcc/testsuite/g++.dg/cpp0x/auto48.C new file mode 100644 index 00000000000..3e0b9ff601e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto48.C @@ -0,0 +1,8 @@ +// PR c++/70540 +// { dg-do compile { target c++11 } } + +void +foo () +{ + auto f = [&] { return f; }; // { dg-error "before deduction" } +}