]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* pt.c (tsubst_copy) [PARM_DECL]: Handle 'this' in NSDMI.
authorJason Merrill <jason@redhat.com>
Mon, 26 Sep 2011 14:26:56 +0000 (10:26 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Sep 2011 14:26:56 +0000 (10:26 -0400)
From-SVN: r179201

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nsdmi-defer4.C
gcc/testsuite/g++.dg/cpp0x/nsdmi-template1.C [new file with mode: 0644]

index fe7589e9c7ef4623a100df7621074c56d40291f2..59b162df7f99923b2831dcd90f6b314e08558b06 100644 (file)
@@ -1,3 +1,7 @@
+2011-09-26  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (tsubst_copy) [PARM_DECL]: Handle 'this' in NSDMI.
+
 2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * pt.c (convert_nontype_argument): Handle NULLPTR_TYPE.
index 2c398e019ab45423283ad3d14c128dbe74042676..cac45f9feb574c2b4480ba4245e8e3461842b1ed 100644 (file)
@@ -11750,6 +11750,13 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       if (r == NULL)
        {
          tree c;
+
+         /* We get here for a use of 'this' in an NSDMI.  */
+         if (DECL_NAME (t) == this_identifier
+             && at_function_scope_p ()
+             && DECL_CONSTRUCTOR_P (current_function_decl))
+           return current_class_ptr;
+
          /* This can happen for a parameter name used later in a function
             declaration (such as in a late-specified return type).  Just
             make a dummy decl, since it's only used for its type.  */
index dde9c62a0d5101ec6e1a42898c416656fd9b320a..e0250194a9037ae51c379cd61294e780e783ca5f 100644 (file)
@@ -1,3 +1,7 @@
+2011-09-26  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/nsdmi-template1.C: New.
+
 2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.dg/cpp0x/nullptr25.C: New.
index 68c8380eed2a26a36dc7ecf5c09d715332f3e540..65b2e738077c5c47d7cfc14cf386e8f0bb449f48 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-options -std=c++0x }
+// { dg-do run }
 
 struct A
 {
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template1.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template1.C
new file mode 100644 (file)
index 0000000..04f1e03
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do run }
+// { dg-options -std=c++0x }
+
+struct base
+{
+  int calc_avg() { return 42; }
+};
+
+template <class T> struct nsdmi : T
+{
+  nsdmi() {}
+  int avg() { return avg_; }
+  int avg_ = this->calc_avg();
+};
+
+int main()
+{
+  nsdmi<base> x;
+  if (x.avg() != 42)
+    __builtin_abort();
+}