summaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-25 16:55:34 +0000
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-25 16:55:34 +0000
commit1fadf2c820097b85041a933084e94a9ee64243c9 (patch)
tree09d2e60d7ceba6434ad38c297762a3642c26dfda /gcc/cp/parser.c
parent6338935c9c4842afb5e62b889b025d326bab5f99 (diff)
downloadgcc-1fadf2c820097b85041a933084e94a9ee64243c9.tar.gz
Friend class name lookup 2/n, PR c++/14513, c++/15410
* name-lookup.c (lookup_name_real): Simplify. (lookup_type_scope): Add SCOPE parameter. Handle friend class lookup. * name-lookup.h (tag_scope): New enum type. (lookup_type_scope): Adjust declaration. * decl.c (lookup_and_check_tag, xref_tag, xref_tag_from_type): Change bool parameter GLOBALIZED to TAG_SCOPE parameter SCOPE. (start_enum): Likewise. Add assertion test that NAME is IDENTIFIER_NODE. Use anonymous name for dummy ENUMERAL_TYPE in case of error. * cp-tree.h (xref_tag, xref_tag_from_type): Adjust declarations. * parser.c (cp_parser_elaborated_type_specifier, cp_parser_class_head): Adjust call to xref_tag. * pt.c (lookup_template_class, instantiate_class_template): Likewise. * rtti.c (init_rtti_processing, build_dynamic_cast_1, tinfo_base_init, emit_support_tinfos): Likewise. * g++.dg/lookup/friend2.C: New test. * g++.dg/template/friend31.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91299 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1a9786845c4..3548b45c117 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -9731,15 +9731,23 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
definition of a new type; a new type can only be declared in a
declaration context. */
+ tag_scope ts;
+ if (is_friend)
+ /* Friends have special name lookup rules. */
+ ts = ts_within_enclosing_non_class;
+ else if (is_declaration
+ && cp_lexer_next_token_is (parser->lexer,
+ CPP_SEMICOLON))
+ /* This is a `class-key identifier ;' */
+ ts = ts_current;
+ else
+ ts = ts_global;
+
/* Warn about attributes. They are ignored. */
if (attributes)
warning ("type attributes are honored only at type definition");
- type = xref_tag (tag_type, identifier,
- (is_friend
- || !is_declaration
- || cp_lexer_next_token_is_not (parser->lexer,
- CPP_SEMICOLON)),
+ type = xref_tag (tag_type, identifier, ts,
parser->num_template_parameter_lists);
}
}
@@ -12642,7 +12650,7 @@ cp_parser_class_head (cp_parser* parser,
/* If the class was unnamed, create a dummy name. */
if (!id)
id = make_anon_name ();
- type = xref_tag (class_key, id, /*globalize=*/false,
+ type = xref_tag (class_key, id, /*tag_scope=*/ts_current,
parser->num_template_parameter_lists);
}
else