Commit 894ca2c9 by Richard Henderson Committed by Richard Henderson

re PR c++/16012 (trouble with scope in for statements in templates)

        PR c++/16012
        * semantics.c (begin_for_stmt, begin_for_stmt): Do put the init
        statement in FOR_INIT_STMT for templates.

From-SVN: r83253
parent e751adc3
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.
......
......@@ -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 ();
......
// { 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>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment