From 9f175208940aa2112b07e440e7601a662a3a1a52 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 17 Dec 2002 01:24:02 -0500 Subject: [PATCH] c-semantics.c (add_scope_stmt): Abort if the end SCOPE_STMT doesn't match the begin SCOPE_STMT in partialness. * c-semantics.c (add_scope_stmt): Abort if the end SCOPE_STMT doesn't match the begin SCOPE_STMT in partialness. cp/ * semantics.c (do_pushlevel): Call pushlevel after adding the SCOPE_STMT. (do_poplevel): Call poplevel before adding the SCOPE_STMT. * parse.y (function_body): Go back to using compstmt. * decl.c (pushdecl): Skip another level to get to the parms level. * call.c (build_new_method_call): Use is_dummy_object to determine whether or not to evaluate the object parameter to a static member function. From-SVN: r60196 --- gcc/ChangeLog | 5 +++++ gcc/c-semantics.c | 2 ++ gcc/cp/ChangeLog | 12 ++++++++++++ gcc/cp/call.c | 2 +- gcc/cp/decl.c | 3 +++ gcc/cp/parse.y | 11 +++-------- gcc/cp/semantics.c | 17 ++++++++++------- 7 files changed, 36 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b9becce14e9..dc1de48e009 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-12-16 Jason Merrill + + * c-semantics.c (add_scope_stmt): Abort if the end SCOPE_STMT + doesn't match the begin SCOPE_STMT in partialness. + 2002-12-16 Geoffrey Keating * genmultilib: Create temporary files in unique subdirectory. diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c index 0b8f5870134..77d7384f9a2 100644 --- a/gcc/c-semantics.c +++ b/gcc/c-semantics.c @@ -146,6 +146,8 @@ add_scope_stmt (begin_p, partial_p) } else { + if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top))) + abort (); TREE_VALUE (top) = ss; *stack_ptr = TREE_CHAIN (top); } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ceafa26e3a7..a1b5038ff6a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2002-12-16 Jason Merrill + + * semantics.c (do_pushlevel): Call pushlevel after adding the + SCOPE_STMT. + (do_poplevel): Call poplevel before adding the SCOPE_STMT. + * parse.y (function_body): Go back to using compstmt. + * decl.c (pushdecl): Skip another level to get to the parms level. + + * call.c (build_new_method_call): Use is_dummy_object to determine + whether or not to evaluate the object parameter to a static member + function. + 2002-12-14 Jason Merrill * semantics.c (simplify_aggr_init_exprs_r): Also prepend the diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f766092f339..cafbb14c5d3 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4908,7 +4908,7 @@ build_new_method_call (tree instance, tree fns, tree args, call = build_over_call (cand, args, flags); /* In an expression of the form `a->f()' where `f' turns out to be a static member function, `a' is none-the-less evaluated. */ - if (instance && TREE_SIDE_EFFECTS (instance)) + if (!is_dummy_object (instance_ptr) && TREE_SIDE_EFFECTS (instance)) call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e3f5b5a9f29..2d6b4a4a28e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4161,6 +4161,9 @@ pushdecl (x) them there. */ struct cp_binding_level *b = current_binding_level->level_chain; + /* Skip the ctor/dtor cleanup level. */ + b = b->level_chain; + /* ARM $8.3 */ if (b->parm_flag == 1) { diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 2f0fd937fcb..4f628412a9b 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -798,15 +798,10 @@ eat_saved_input: ; /* The outermost block of a function really begins before the - mem-initializer-list, so we open one there and suppress the one that - actually corresponds to the curly braces. */ + mem-initializer-list, so we open one there, too. */ function_body: - begin_function_body_ ctor_initializer_opt save_lineno '{' - { $$ = begin_compound_stmt (/*has_no_scope=*/1); } - compstmtend - { - STMT_LINENO ($5) = $3; - finish_compound_stmt (/*has_no_scope=*/1, $5); + begin_function_body_ ctor_initializer_opt compstmt + { finish_function_body ($1); } ; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1ceb1f37261..763916acbac 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -125,14 +125,17 @@ do_poplevel () { tree scope_stmts = NULL_TREE; - if (!processing_template_decl) - scope_stmts = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); - block = poplevel (kept_level_p (), 1, 0); - if (block && !processing_template_decl) + if (!processing_template_decl) { - SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block; - SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block; + /* This needs to come after the poplevel so that partial scopes + are properly nested. */ + scope_stmts = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); + if (block) + { + SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block; + SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block; + } } } @@ -146,9 +149,9 @@ do_pushlevel () { if (stmts_are_full_exprs_p ()) { - pushlevel (0); if (!processing_template_decl) add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0); + pushlevel (0); } }