PR c++/34336
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Dec 2007 09:33:26 +0000 (09:33 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Dec 2007 09:33:26 +0000 (09:33 +0000)
* tree.c (stabilize_call, stabilize_init): Do nothing if
processing_template_decl.

* g++.dg/template/new8.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130645 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/new8.C [new file with mode: 0644]

index 98316fe..f7e8904 100644 (file)
@@ -1,3 +1,9 @@
+2007-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/34336
+       * tree.c (stabilize_call, stabilize_init): Do nothing if
+       processing_template_decl.
+
 2007-12-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/34271
index c885d08..843f6c4 100644 (file)
@@ -2602,8 +2602,11 @@ stabilize_call (tree call, tree *initp)
   int i;
   int nargs = call_expr_nargs (call);
 
-  if (call == error_mark_node)
-    return;
+  if (call == error_mark_node || processing_template_decl)
+    {
+      *initp = NULL_TREE;
+      return;
+    }
 
   gcc_assert (TREE_CODE (call) == CALL_EXPR);
 
@@ -2662,7 +2665,7 @@ stabilize_init (tree init, tree *initp)
 
   *initp = NULL_TREE;
 
-  if (t == error_mark_node)
+  if (t == error_mark_node || processing_template_decl)
     return true;
 
   if (TREE_CODE (t) == INIT_EXPR
index e63a9f1..94e7273 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/34336
+       * g++.dg/template/new8.C: New test.
+
 2007-12-06  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/34333
diff --git a/gcc/testsuite/g++.dg/template/new8.C b/gcc/testsuite/g++.dg/template/new8.C
new file mode 100644 (file)
index 0000000..b8f3f97
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/34336
+// { dg-do compile }
+
+struct A;
+
+template <class T>
+struct S
+{
+  T *m;
+  T &operator* () { return *m; }
+};
+
+struct B
+{
+  B (const A &);
+};
+
+template <class T>
+struct C
+{
+  C ();
+  S<A> c;
+};
+
+template <class T>
+C<T>::C ()
+{
+  B *b = new B (*c);
+}