re PR c++/58612 ([c++11] ICE calling non-constexpr from constexpr in template class)
authorJason Merrill <jason@redhat.com>
Mon, 14 Jul 2014 05:25:25 +0000 (01:25 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 14 Jul 2014 05:25:25 +0000 (01:25 -0400)
PR c++/58612
* tree.c (bot_replace): Only replace a dummy 'this' parm.

From-SVN: r212505

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

index 45116eb70b3a4159793ad755b4b3bf2a7c676a7c..63f68dc2bb262db86f7270f4cf9470f37dda38d5 100644 (file)
@@ -1,5 +1,8 @@
 2014-07-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/58612
+       * tree.c (bot_replace): Only replace a dummy 'this' parm.
+
        PR c++/60628
        * decl.c (create_array_type_for_decl): Only check for auto once.
 
index 7ff593564cab2b74e87d7a0441b658278f2140c7..e7823663f5ea53b9bb2c6b1b5275244b886982fd 100644 (file)
@@ -2353,7 +2353,8 @@ bot_replace (tree* t, int* /*walk_subtrees*/, void* data)
        *t = (tree) n->value;
     }
   else if (TREE_CODE (*t) == PARM_DECL
-          && DECL_NAME (*t) == this_identifier)
+          && DECL_NAME (*t) == this_identifier
+          && !DECL_CONTEXT (*t))
     {
       /* In an NSDMI we need to replace the 'this' parameter we used for
         parsing with the real one for this function.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C
new file mode 100644 (file)
index 0000000..55bb838
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/58612
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  int foo() const { return 0; }
+};
+
+template<typename> struct B
+{
+  A a;
+  constexpr int bar() { return a.foo(); } // { dg-error "foo" }
+};
+
+constexpr int i = B<void>().bar(); // { dg-error "bar" }