diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-16 17:59:07 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-16 17:59:07 +0000 |
commit | 5250373abaad4c66dd3fc4b6d0ef3ad1ecfdf82d (patch) | |
tree | dd5662f9db85cb749d8b6177430ec74783e363cc /gcc | |
parent | a788cdfff53eaca99832ca1eed267b24538d53c5 (diff) | |
download | ppe42-gcc-5250373abaad4c66dd3fc4b6d0ef3ad1ecfdf82d.tar.gz ppe42-gcc-5250373abaad4c66dd3fc4b6d0ef3ad1ecfdf82d.zip |
PR c++/16012
* semantics.c (begin_for_stmt, begin_for_stmt): Do put the init
statement in FOR_INIT_STMT for templates.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83253 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/for2.C | 13 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c8a1a1e5e9c..d700297e831 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-06-16 Richard Henderson <rth@redhat.com> + + PR c++/16012 + * semantics.c (begin_for_stmt, begin_for_stmt): Do put the init + statement in FOR_INIT_STMT for templates. + 2004-06-15 Richard Henderson <rth@redhat.com> * call.c (initialize_reference): Don't build CLEANUP_STMT here. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index eeb66c59559..ef82cb1bcb8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -652,6 +652,9 @@ begin_for_stmt (void) if (flag_new_for_scope > 0) TREE_CHAIN (r) = do_pushlevel (sk_for); + if (processing_template_decl) + FOR_INIT_STMT (r) = push_stmt_list (); + return r; } @@ -661,6 +664,8 @@ begin_for_stmt (void) void finish_for_init_stmt (tree for_stmt) { + if (processing_template_decl) + FOR_INIT_STMT (for_stmt) = pop_stmt_list (FOR_INIT_STMT (for_stmt)); add_stmt (for_stmt); FOR_BODY (for_stmt) = do_pushlevel (sk_block); FOR_COND (for_stmt) = push_stmt_list (); diff --git a/gcc/testsuite/g++.dg/init/for2.C b/gcc/testsuite/g++.dg/init/for2.C new file mode 100644 index 00000000000..d66fea30ef2 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/for2.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// PR 16012: Got the scope of I incorrect in templates only. + +template<int> void foo() +{ + for (int i=0 ;;) ; + int i; +} + +void bar() +{ + foo<0>(); +} |