]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/54277 (Template class member referred to with implicit this inside lambda...
authorJason Merrill <jason@redhat.com>
Sat, 23 Mar 2013 16:55:50 +0000 (12:55 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 23 Mar 2013 16:55:50 +0000 (12:55 -0400)
PR c++/54277
* semantics.c (lambda_capture_field_type): Don't build a
magic decltype for pointer types.
(lambda_proxy_type): Likewise.
(finish_non_static_data_member): Get the quals from
the object.

From-SVN: r197009

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this9.C [new file with mode: 0644]

index 7cf4e666608818fb17e53b34f5dc820eb182f059..b22536262b679f4e163059d5087d604bc06f555d 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/54277
+       * semantics.c (lambda_capture_field_type): Don't build a
+       magic decltype for pointer types.
+       (lambda_proxy_type): Likewise.
+       (finish_non_static_data_member): Get the quals from
+       the object.
+
 2013-03-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/56646
index 0ad32a085180a7a1d0fcdcc9ceba16f1fce92211..8735c8c799d50f5d3fd596641ecdd2b56c89f177 100644 (file)
@@ -1570,9 +1570,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
       else
        {
          /* Set the cv qualifiers.  */
-         int quals = (current_class_ref
-                      ? cp_type_quals (TREE_TYPE (current_class_ref))
-                      : TYPE_UNQUALIFIED);
+         int quals = cp_type_quals (TREE_TYPE (object));
 
          if (DECL_MUTABLE_P (decl))
            quals &= ~TYPE_QUAL_CONST;
@@ -8815,7 +8813,8 @@ tree
 lambda_capture_field_type (tree expr)
 {
   tree type;
-  if (type_dependent_expression_p (expr))
+  if (type_dependent_expression_p (expr)
+      && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE))
     {
       type = cxx_make_type (DECLTYPE_TYPE);
       DECLTYPE_TYPE_EXPR (type) = expr;
@@ -9020,7 +9019,8 @@ lambda_proxy_type (tree ref)
   if (REFERENCE_REF_P (ref))
     ref = TREE_OPERAND (ref, 0);
   type = TREE_TYPE (ref);
-  if (!dependent_type_p (type))
+  if (!dependent_type_p (type)
+      || (type && TREE_CODE (type) == POINTER_TYPE))
     return type;
   type = cxx_make_type (DECLTYPE_TYPE);
   DECLTYPE_TYPE_EXPR (type) = ref;
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this9.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this9.C
new file mode 100644 (file)
index 0000000..07ddd08
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/54277
+// { dg-do compile { target c++11 } }
+
+struct Used
+{
+  void foo() { }
+};
+
+template <typename>
+struct S
+{
+  Used x;
+
+  void bar()
+  {
+    auto f = [this] { x.foo(); };
+    f();
+  }
+};