From: Eric Botcazou Date: Mon, 18 Mar 2002 20:19:39 +0000 (+0000) Subject: re PR c++/3882 (gcc 3.0 error referencing a variable in its initializer expression... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff77ac85500988bc8f54a1e36ea8ee843b63588b;p=gcc.git re PR c++/3882 (gcc 3.0 error referencing a variable in its initializer expression in template code) 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6b791d54bde..4d3e3094962 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2002-03-18 Eric Botcazou + + 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 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 index 00000000000..50eef08663b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/decl1.C @@ -0,0 +1,16 @@ +// PR c++/3882 +// Verify that variable initialization can be +// self-referencing inside a template function. + +int foo(int); + +template +void bar(const T&) +{ + int i = foo(i); +} + +void quus() +{ + bar(0); +}