re PR c++/3882 (gcc 3.0 error referencing a variable in its initializer expression...
authorEric Botcazou <ebotcazou@multimania.com>
Mon, 18 Mar 2002 20:19:39 +0000 (20:19 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 18 Mar 2002 20:19:39 +0000 (15:19 -0500)
        PR c++/3882
        * pt.c (tsubst_decl): Move __PRETTY_FUNCTION__ handling...
        (tsubst_expr) [DECL_STMT]: ...here. And substitute the initializer
        only after recording the declaration.

From-SVN: r50999

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

index 6b791d54bde50a1cfe65ce5cb0ccfb32a400fc97..4d3e30949627e5b4004c51fd870762ceb213b50e 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-18  Eric Botcazou  <ebotcazou@multimania.com>
+
+       PR c++/3882
+       * pt.c (tsubst_decl): Move __PRETTY_FUNCTION__ handling...
+       (tsubst_expr) [DECL_STMT]: ...here. And substitute the initializer
+       only after recording the declaration.
+
 2002-03-18  Jason Merrill  <jason@redhat.com>
 
        PR c++/2039
diff --git a/gcc/testsuite/g++.dg/template/decl1.C b/gcc/testsuite/g++.dg/template/decl1.C
new file mode 100644 (file)
index 0000000..50eef08
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/3882
+// Verify that variable initialization can be
+// self-referencing inside a template function.
+
+int foo(int);
+
+template <typename T>
+void bar(const T&)
+{
+  int i = foo(i);
+}
+
+void quus()
+{
+  bar(0);
+}