diff options
author | Eric Botcazou <ebotcazou@multimania.com> | 2002-03-18 20:19:39 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-03-18 15:19:39 -0500 |
commit | ff77ac85500988bc8f54a1e36ea8ee843b63588b (patch) | |
tree | 0072ba95d96d9521a766c7decf6ca20dcf6aa0e0 | |
parent | ed30079302a7b50092afc26ce47809ab03c59483 (diff) | |
download | gcc-ff77ac85500988bc8f54a1e36ea8ee843b63588b.zip gcc-ff77ac85500988bc8f54a1e36ea8ee843b63588b.tar.gz gcc-ff77ac85500988bc8f54a1e36ea8ee843b63588b.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/decl1.C | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6b791d5..4d3e309 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 index 0000000..50eef08 --- /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 <typename T> +void bar(const T&) +{ + int i = foo(i); +} + +void quus() +{ + bar(0); +} |