diff options
author | Jason Merrill <jason@redhat.com> | 2002-10-18 05:00:47 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-10-18 05:00:47 -0400 |
commit | 5275f2bf280fa76d637b1a6f4bfd522a6de2d507 (patch) | |
tree | 04bd032d2ea68de1eb2968b0a9780b22d2fee2a3 | |
parent | 8a188e24900cfb30734df5e40cfb0e1ee88750b6 (diff) | |
download | gcc-5275f2bf280fa76d637b1a6f4bfd522a6de2d507.zip gcc-5275f2bf280fa76d637b1a6f4bfd522a6de2d507.tar.gz gcc-5275f2bf280fa76d637b1a6f4bfd522a6de2d507.tar.bz2 |
re PR c++/8080 ([Regression in main trunk] g++ 3.3 ICE in make_decl_rtl)
PR c++/8080
* semantics.c (finish_for_cond, finish_while_stmt_cond): Don't mess
with condition decls in a template.
From-SVN: r58282
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/cond.C | 23 |
3 files changed, 37 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e2a0976..bdceab0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-10-18 Jason Merrill <jason@redhat.com> + + PR c++/8080 + * semantics.c (finish_for_cond, finish_while_cond): Don't mess + with condition decls in a template. + 2002-10-17 Nathan Sidwell <nathan@codesourcery.com> * class.c (add_method): Compare template parms too. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 27fa97a..c561a66 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -317,7 +317,10 @@ finish_while_stmt_cond (cond, while_stmt) tree while_stmt; { cond = maybe_convert_cond (cond); - if (getdecls () == NULL_TREE) + if (processing_template_decl) + /* Don't mess with condition decls in a template. */ + FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt)); + else if (getdecls () == NULL_TREE) /* It was a simple condition; install it. */ WHILE_COND (while_stmt) = cond; else @@ -452,7 +455,10 @@ finish_for_cond (cond, for_stmt) tree for_stmt; { cond = maybe_convert_cond (cond); - if (getdecls () == NULL_TREE) + if (processing_template_decl) + /* Don't mess with condition decls in a template. */ + FINISH_COND (cond, for_stmt, FOR_COND (for_stmt)); + else if (getdecls () == NULL_TREE) /* It was a simple condition; install it. */ FOR_COND (for_stmt) = cond; else diff --git a/gcc/testsuite/g++.dg/template/cond.C b/gcc/testsuite/g++.dg/template/cond.C new file mode 100644 index 0000000..394a21c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/cond.C @@ -0,0 +1,23 @@ +// PR c++/8080 + +// Bug: the transformation in finish_while_stmt_cond produced something +// that tsubst_expr handled badly. Fixed by not doing the transformation +// while parsing a template. + +class TObject {}; + +struct TIter { + TObject *operator()(); +}; + + +template<class T> +void get_root_object(TIter& iobj) { + while ( TObject* pnew_obj = iobj() ) + ; +} + +void foo(TIter& iobj) +{ + get_root_object<int>(iobj); +} |