This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/58612 (constexpr ICE)


When we call break_out_target_exprs in the middle of explain_invalid_constexpr_fn, we don't want to replace 'this' with whatever current_class_ptr is at that point.

Tested x86_64-pc-linux-gnu, applying to trunk.
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.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 7ff5935..e782366 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 0000000..55bb838
--- /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<typename> struct B
+{
+  A a;
+  constexpr int bar() { return a.foo(); } // { dg-error "foo" }
+};
+
+constexpr int i = B<void>().bar(); // { dg-error "bar" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]