From: Jason Merrill Date: Mon, 14 Jul 2014 05:25:25 +0000 (-0400) Subject: re PR c++/58612 ([c++11] ICE calling non-constexpr from constexpr in template class) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22c6ea004237e0dd3aebdfec3cbaad138bec06df;p=gcc.git re PR c++/58612 ([c++11] ICE calling non-constexpr from constexpr in template class) PR c++/58612 * tree.c (bot_replace): Only replace a dummy 'this' parm. From-SVN: r212505 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 45116eb70b3..63f68dc2bb2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-07-13 Jason Merrill + 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. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7ff593564ca..e7823663f5e 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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 index 00000000000..55bb838a2bf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C @@ -0,0 +1,15 @@ +// PR c++/58612 +// { dg-do compile { target c++11 } } + +struct A +{ + int foo() const { return 0; } +}; + +template struct B +{ + A a; + constexpr int bar() { return a.foo(); } // { dg-error "foo" } +}; + +constexpr int i = B().bar(); // { dg-error "bar" }