commit b520b30e2e4bf0174eea966cdccac36eefc5a544
Author: Jason Merrill <jason@redhat.com>
Date: Sun Jul 13 12:52:54 2014 -0400
PR c++/58612
* tree.c (bot_replace): Only replace a dummy 'this' parm.
@@ -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. */
new file mode 100644
@@ -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" }