diff mbox

C++ PATCH for c++/47971 (ICE with pseudo-dtor call in template)

Message ID 4D711473.1000300@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 4, 2011, 4:33 p.m. UTC
Another case of wrongly treating a type as an expression.  I've also 
changed tsubst_copy to only abort when this happens in checking mode; 
simply returning the argument worked OK in previous releases.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 45546accfd674ac13c8a469c616f1abcfb96743a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 3 18:52:23 2011 -0500

    	PR c++/47971
    	* pt.c (tsubst_copy_and_build) [PSEUDO_DTOR_EXPR]: Use tsubst for type.
    	(tsubst_copy) [default]: Just return t if !ENABLE_CHECKING.
diff mbox

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 60b2699..453f1bd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11722,7 +11722,9 @@  tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       return t;
 
     default:
-      gcc_unreachable ();
+      /* We shouldn't get here, but keep going if !ENABLE_CHECKING.  */
+      gcc_checking_assert (false);
+      return t;
     }
 }
 
@@ -12979,7 +12981,7 @@  tsubst_copy_and_build (tree t,
       return finish_pseudo_destructor_expr
 	(RECUR (TREE_OPERAND (t, 0)),
 	 RECUR (TREE_OPERAND (t, 1)),
-	 RECUR (TREE_OPERAND (t, 2)));
+	 tsubst (TREE_OPERAND (t, 2), args, complain, in_decl));
 
     case TREE_LIST:
       {
diff --git a/gcc/testsuite/g++.dg/template/pseudodtor6.C b/gcc/testsuite/g++.dg/template/pseudodtor6.C
new file mode 100644
index 0000000..4438b6f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pseudodtor6.C
@@ -0,0 +1,9 @@ 
+// PR c++/47971
+
+template <typename> struct S
+{
+  typedef double T;
+  S () { T ().~T (); }
+};
+
+S<double> s;