* C++ PATCH to fix SCOPE_STMT nesting
@ 2002-12-16 22:23 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2002-12-16 22:23 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
While working on tree-ssa stuff, I noticed that there were still some cases
where SCOPE_STMTs weren't nesting properly. In one case, we had
overlapping partial and non-partial scopes, and in another we had a scope
that began inside a COMPOUND_STMT and ended outside it. Fixed thus.
The call.c change is unrelated; it fixes another bug whereby -fvolatile was
causing us to try to evaluate the address of void_zero_node; this only
seems to be a problem on the tree-ssa branch, but the fix is correct
regardless.
Tested i686-pc-linux-gnu, applied to trunk.
2002-12-16 Jason Merrill <jason@redhat.com>
* 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3987 bytes --]
*** ./cp/call.c.~1~ Mon Dec 16 17:15:29 2002
--- ./cp/call.c Mon Dec 16 22:25:53 2002
*************** build_new_method_call (tree instance, tr
*** 4908,4914 ****
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))
call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call);
}
--- 4908,4914 ----
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 (!is_dummy_object (instance_ptr) && TREE_SIDE_EFFECTS (instance))
call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call);
}
*** ./cp/parse.y.~1~ Mon Dec 16 17:15:29 2002
--- ./cp/parse.y Mon Dec 16 23:40:05 2002
*************** eat_saved_input:
*** 798,812 ****
;
/* 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. */
function_body:
! begin_function_body_ ctor_initializer_opt save_lineno '{'
! { $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
! compstmtend
! {
! STMT_LINENO ($<ttype>5) = $3;
! finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
finish_function_body ($1);
}
;
--- 798,807 ----
;
/* The outermost block of a function really begins before the
! mem-initializer-list, so we open one there, too. */
function_body:
! begin_function_body_ ctor_initializer_opt compstmt
! {
finish_function_body ($1);
}
;
*** ./cp/semantics.c.~1~ Mon Dec 16 17:15:29 2002
--- ./cp/semantics.c Mon Dec 16 22:25:53 2002
*************** do_poplevel ()
*** 125,138 ****
{
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)
{
! SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
! SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
}
}
--- 125,141 ----
{
tree scope_stmts = NULL_TREE;
block = poplevel (kept_level_p (), 1, 0);
! if (!processing_template_decl)
{
! /* 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;
! }
}
}
*************** do_pushlevel ()
*** 146,154 ****
{
if (stmts_are_full_exprs_p ())
{
- pushlevel (0);
if (!processing_template_decl)
add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
}
}
--- 149,157 ----
{
if (stmts_are_full_exprs_p ())
{
if (!processing_template_decl)
add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
+ pushlevel (0);
}
}
*** ./cp/decl.c.~1~ Mon Dec 16 15:45:09 2002
--- ./cp/decl.c Mon Dec 16 23:40:05 2002
*************** pushdecl (x)
*** 4161,4166 ****
--- 4161,4169 ----
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)
{
*** ./c-semantics.c.~1~ Mon Dec 16 17:15:29 2002
--- ./c-semantics.c Mon Dec 16 22:25:53 2002
*************** add_scope_stmt (begin_p, partial_p)
*** 146,151 ****
--- 146,153 ----
}
else
{
+ if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top)))
+ abort ();
TREE_VALUE (top) = ss;
*stack_ptr = TREE_CHAIN (top);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-17 6:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-16 22:23 C++ PATCH to fix SCOPE_STMT nesting Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).