]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58596 ([c++11] ICE with decltype in non-static data member initializer)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 17 Oct 2013 16:58:45 +0000 (16:58 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 17 Oct 2013 16:58:45 +0000 (16:58 +0000)
/cp
2013-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58596
* lambda.c (lambda_expr_this_capture): Handle NSDMIs in the
cp_unevaluated_operand case.

/testsuite
2013-10-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58596
* g++.dg/cpp0x/lambda/lambda-nsdmi5.C: New

From-SVN: r203780

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

index 9b15f5556873237c9ac996061ad63a254ec9c777..3ce68e8e75c00e548b2d0ba59d75b24d02972a70 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58596
+       * lambda.c (lambda_expr_this_capture): Handle NSDMIs in the
+       cp_unevaluated_operand case.
+
 2013-10-16  Jason Merrill  <jason@redhat.com>
 
        * pt.c (apply_late_template_attributes): Use
index 2ecb17cfe916220b15f201c5d8982ec218edaae2..62812a50c85c0b261c853990bb9f11abe348ad07 100644 (file)
@@ -628,7 +628,14 @@ lambda_expr_this_capture (tree lambda)
   /* In unevaluated context this isn't an odr-use, so just return the
      nearest 'this'.  */
   if (cp_unevaluated_operand)
-    return lookup_name (this_identifier);
+    {
+      /* In an NSDMI the fake 'this' pointer that we're using for
+        parsing is in scope_chain.  */
+      if (LAMBDA_EXPR_EXTRA_SCOPE (lambda)
+         && TREE_CODE (LAMBDA_EXPR_EXTRA_SCOPE (lambda)) == FIELD_DECL)
+       return scope_chain->x_current_class_ptr;
+      return lookup_name (this_identifier);
+    }
 
   /* Try to default capture 'this' if we can.  */
   if (!this_capture
index a3bd224b63d7d2c2036be079466a385cefbe1664..4c6c320c540fcd5622fdec5952f6c297f039e6bc 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58596
+       * g++.dg/cpp0x/lambda/lambda-nsdmi5.C: New
+
 2013-10-17  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.target/aarch64/c-output-template.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C
new file mode 100644 (file)
index 0000000..1d2778f
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/58596
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  int i = [] { return decltype(i)(); }();
+};