===================================================================
@@ -0,0 +1,23 @@
+// PR c++/47795
+// { dg-options "-std=c++0x" }
+
+class Klass
+{
+ unsigned int local;
+public:
+ bool dostuff();
+};
+
+bool Klass::dostuff()
+{
+ auto f = []() -> bool {
+ if (local & 1) { return true; } // { dg-error "not captured" }
+ return false;
+ };
+}
+
+int main()
+{
+ Klass c;
+ return 0;
+}
===================================================================
@@ -1533,6 +1533,9 @@ finish_non_static_data_member (tree decl, tree obj
object = maybe_dummy_object (scope, NULL);
}
+ if (object == error_mark_node)
+ return error_mark_node;
+
/* DR 613: Can use non-static data members without an associated
object in sizeof/decltype/alignof. */
if (is_dummy_object (object) && cp_unevaluated_operand == 0