Commit 1f51a992 by Jason Merrill Committed by Jason Merrill

semantics.c (deferred_type_access_control): Walk the entire type_lookups list.

        * semantics.c (deferred_type_access_control): Walk the entire
        type_lookups list.
        (save_type_access_control): Rename from
        initial_deferred_type_access_control.  Just remember the value.
        (decl_type_access_control): New fn.
        (begin_function_definition): Use deferred_type_access_control, after
        we've started the function.  Set type_lookups to error_mark_node.
        * parse.y (frob_specs, fn.def1): Adjust.
        (parse_decl0, parse_field, parse_field0, parse_bitfield): New fns.
        (parse_end_decl, parse_bitfield0, parse_method): New fns.
        (fn.def2, initdcl, initdcl0_innards, nomods_initdcl0): Use them.
        (after_type_component_declarator0): Likewise.
        (after_type_component_declarator): Likewise.
        (notype_component_declarator): Likewise.
        * cp-tree.h: Adjust.

        * decl.c (redeclaration_error_message): Allow redeclaration of
        namespace-scope decls.

From-SVN: r32059
parent 6d1e16d7
2000-02-18 Jason Merrill <jason@casey.cygnus.com>
* semantics.c (deferred_type_access_control): Walk the entire
type_lookups list.
(save_type_access_control): Rename from
initial_deferred_type_access_control. Just remember the value.
(decl_type_access_control): New fn.
(begin_function_definition): Use deferred_type_access_control, after
we've started the function. Set type_lookups to error_mark_node.
* parse.y (frob_specs, fn.def1): Adjust.
(parse_decl0, parse_field, parse_field0, parse_bitfield): New fns.
(parse_end_decl, parse_bitfield0, parse_method): New fns.
(fn.def2, initdcl, initdcl0_innards, nomods_initdcl0): Use them.
(after_type_component_declarator0): Likewise.
(after_type_component_declarator): Likewise.
(notype_component_declarator): Likewise.
* cp-tree.h: Adjust.
* decl.c (redeclaration_error_message): Allow redeclaration of
namespace-scope decls.
2000-02-18 Martin von Loewis <loewis@informatik.hu-berlin.de> 2000-02-18 Martin von Loewis <loewis@informatik.hu-berlin.de>
* typeck2.c (my_friendly_abort): Use GCCBUGURL. * typeck2.c (my_friendly_abort): Use GCCBUGURL.
......
...@@ -4177,9 +4177,9 @@ extern tree finish_qualified_call_expr PARAMS ((tree, tree)); ...@@ -4177,9 +4177,9 @@ extern tree finish_qualified_call_expr PARAMS ((tree, tree));
extern tree finish_label_address_expr PARAMS ((tree)); extern tree finish_label_address_expr PARAMS ((tree));
extern tree finish_unary_op_expr PARAMS ((enum tree_code, tree)); extern tree finish_unary_op_expr PARAMS ((enum tree_code, tree));
extern tree finish_id_expr PARAMS ((tree)); extern tree finish_id_expr PARAMS ((tree));
extern void deferred_type_access_control PARAMS ((void)); extern void save_type_access_control PARAMS ((tree));
extern void initial_deferred_type_access_control PARAMS ((tree)); extern void decl_type_access_control PARAMS ((tree));
extern int begin_function_definition PARAMS ((tree, tree, tree)); extern int begin_function_definition PARAMS ((tree, tree));
extern tree begin_constructor_declarator PARAMS ((tree, tree)); extern tree begin_constructor_declarator PARAMS ((tree, tree));
extern tree finish_declarator PARAMS ((tree, tree, tree, tree, int)); extern tree finish_declarator PARAMS ((tree, tree, tree, tree, int));
extern void finish_translation_unit PARAMS ((void)); extern void finish_translation_unit PARAMS ((void));
......
...@@ -4585,7 +4585,7 @@ redeclaration_error_message (newdecl, olddecl) ...@@ -4585,7 +4585,7 @@ redeclaration_error_message (newdecl, olddecl)
return "redefinition of `%#D'"; return "redefinition of `%#D'";
return 0; return 0;
} }
else if (toplevel_bindings_p ()) else if (toplevel_bindings_p () || DECL_NAMESPACE_SCOPE_P (newdecl))
{ {
/* Objects declared at top level: */ /* Objects declared at top level: */
/* If at least one is a reference, it's ok. */ /* If at least one is a reference, it's ok. */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1097,15 +1097,14 @@ friend_accessible_p (scope, type, decl, binfo) ...@@ -1097,15 +1097,14 @@ friend_accessible_p (scope, type, decl, binfo)
When we are done with the decl-specifier-seq, we record the lookups we've When we are done with the decl-specifier-seq, we record the lookups we've
seen in the lookups field of the typed_declspecs nonterminal. seen in the lookups field of the typed_declspecs nonterminal.
When we process the first declarator, either in parse_decl or When we process the first declarator, either in parse_decl or
begin_function_definition, we call initial_deferred_type_access_control, begin_function_definition, we call save_type_access_control,
which processes any lookups from within that declarator, stores the which stores the lookups from the decl-specifier-seq in
lookups from the decl-specifier-seq in current_type_lookups, and sets current_type_lookups.
type_lookups to error_mark_node. As we finish with each declarator, we process everything in type_lookups
Subsequent declarators process current_type_lookups again to make sure via decl_type_access_control, which resets type_lookups to the value of
that the types are accessible to all of the declarators. Any lookups current_type_lookups for subsequent declarators.
within subsequent declarators are processed immediately. When we enter a function, we set type_lookups to error_mark_node, so all
Within a function, type_lookups is error_mark_node, so all lookups are lookups are processed immediately. */
processed immediately. */
void void
type_access_control (type, val) type_access_control (type, val)
......
...@@ -1695,10 +1695,10 @@ static tree current_type_lookups; ...@@ -1695,10 +1695,10 @@ static tree current_type_lookups;
/* Perform deferred access control for types used in the type of a /* Perform deferred access control for types used in the type of a
declaration. */ declaration. */
void static void
deferred_type_access_control () deferred_type_access_control ()
{ {
tree lookup = current_type_lookups; tree lookup = type_lookups;
if (lookup == error_mark_node) if (lookup == error_mark_node)
return; return;
...@@ -1707,46 +1707,56 @@ deferred_type_access_control () ...@@ -1707,46 +1707,56 @@ deferred_type_access_control ()
enforce_access (TREE_PURPOSE (lookup), TREE_VALUE (lookup)); enforce_access (TREE_PURPOSE (lookup), TREE_VALUE (lookup));
} }
/* Perform deferred access control for types used in the type of a
declaration. Called for the first declarator in a declaration. */
void void
initial_deferred_type_access_control (lookups) decl_type_access_control (decl)
tree lookups; tree decl;
{ {
tree lookup = type_lookups; tree save_fn;
/* First perform the checks for the current declarator; they will have if (type_lookups == error_mark_node)
been added to type_lookups since typed_declspecs saved the copy that return;
we have been passed. */
if (lookup != error_mark_node) save_fn = current_function_decl;
for (; lookup != lookups; lookup = TREE_CHAIN (lookup))
enforce_access (TREE_PURPOSE (lookup), TREE_VALUE (lookup)); if (decl && TREE_CODE (decl) == FUNCTION_DECL)
current_function_decl = decl;
current_type_lookups = lookups;
type_lookups = error_mark_node;
deferred_type_access_control (); deferred_type_access_control ();
}
current_function_decl = save_fn;
/* Now strip away the checks for the current declarator; they were
added to type_lookups after typed_declspecs saved the copy that
ended up in current_type_lookups. */
type_lookups = current_type_lookups;
}
void
save_type_access_control (lookups)
tree lookups;
{
current_type_lookups = lookups;
}
/* Begin a function definition declared with DECL_SPECS and /* Begin a function definition declared with DECL_SPECS and
DECLARATOR. Returns non-zero if the function-declaration is DECLARATOR. Returns non-zero if the function-declaration is
legal. */ legal. */
int int
begin_function_definition (decl_specs, lookups, declarator) begin_function_definition (decl_specs, declarator)
tree decl_specs; tree decl_specs;
tree lookups;
tree declarator; tree declarator;
{ {
tree specs; tree specs;
tree attrs; tree attrs;
initial_deferred_type_access_control (lookups);
split_specs_attrs (decl_specs, &specs, &attrs); split_specs_attrs (decl_specs, &specs, &attrs);
if (!start_function (specs, declarator, attrs, SF_DEFAULT)) if (!start_function (specs, declarator, attrs, SF_DEFAULT))
return 0; return 0;
deferred_type_access_control ();
type_lookups = error_mark_node;
reinit_parse_for_function (); reinit_parse_for_function ();
/* The things we're about to see are not directly qualified by any /* The things we're about to see are not directly qualified by any
template headers we've seen thus far. */ template headers we've seen thus far. */
......
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