commit 80bb7027cca5a7c0db92fb0338ae55cb44e9b3d6
Author: Jason Merrill <jason@redhat.com>
Date: Tue Jul 9 02:59:52 2013 -0400
PR c++/57526
* semantics.c (lambda_capture_field_type): Build a DECLTYPE_TYPE
if the variable type uses 'auto'.
@@ -9078,7 +9078,8 @@ lambda_capture_field_type (tree expr)
{
tree type;
if (type_dependent_expression_p (expr)
- && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE))
+ && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE
+ && !type_uses_auto (TREE_TYPE (expr))))
{
type = cxx_make_type (DECLTYPE_TYPE);
DECLTYPE_TYPE_EXPR (type) = expr;
new file mode 100644
@@ -0,0 +1,24 @@
+// PR c++/57526
+// { dg-require-effective-target c++11 }
+
+template<class T>
+struct A
+{
+ void bar( ) { }
+
+ void foo( )
+ {
+ auto* this_ptr = this;
+ auto lc = [&]( )
+ {
+ this_ptr->bar();
+ };
+ lc();
+ }
+};
+
+int main()
+{
+ A<int> a;
+ a.foo();
+}