From 91caa6ca3986bf788a691be18aec8cafe401a1a0 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Wed, 4 Aug 2004 05:27:52 +0000 Subject: * class.c (build_vtable): Do not set DECL_VISIBILITY here. (check_field_decls): Or here. (check_methods): Or here. (initialize_array): Don't mess with DECL_CONTEXT. * cp-tree.h (start_decl): Adjust prototype. (determine_visibility): New function. * decl.c (duplicate_decls): Remove checks for hidden "operator new". (build_library_fn_1): Give all library functions default visibility. (start_decl): Add pop_scope_p parameter. Tidy. (cp_finish_decl): Do not pop scopes here. Call determine_visibility for variable definitions. (start_preparsed_function): Call determine_visibility. * decl2.c (determine_visibility): New function. * method.c (use_thunk): Fix formatting. * parser.c (cp_parser_condition): Adjust calls to start_decl. (cp_parser_init_declarator): Likewise. * pt.c (instantiate_decl): Always call pop_nested_class. * rtti.c (get_tinfo_decl): Do not set DECL_VISIBILITY. (tinfo_base_init): Likewise. * g++.dg/ext/visibility/assign1.C: New test. * g++.dg/ext/visibility/new1.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85543 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/parser.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'gcc/cp/parser.c') diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f19ab252e27..d6aadb37cd7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6312,10 +6312,13 @@ cp_parser_condition (cp_parser* parser) for sure. */ if (cp_parser_parse_definitely (parser)) { + bool pop_p; + /* Create the declaration. */ decl = start_decl (declarator, &type_specifiers, /*initialized_p=*/true, - attributes, /*prefix_attributes=*/NULL_TREE); + attributes, /*prefix_attributes=*/NULL_TREE, + &pop_p); /* Parse the assignment-expression. */ initializer = cp_parser_assignment_expression (parser); @@ -6324,6 +6327,8 @@ cp_parser_condition (cp_parser* parser) initializer, asm_specification, LOOKUP_ONLYCONVERTING); + if (pop_p) + pop_scope (DECL_CONTEXT (decl)); return convert_from_reference (decl); } @@ -10630,12 +10635,12 @@ cp_parser_init_declarator (cp_parser* parser, have_extern_spec = false; } decl = start_decl (declarator, decl_specifiers, - is_initialized, attributes, prefix_attributes); + is_initialized, attributes, prefix_attributes, + &pop_p); } - - /* Enter the SCOPE. That way unqualified names appearing in the - initializer will be looked up in SCOPE. */ - if (scope) + else if (scope) + /* Enter the SCOPE. That way unqualified names appearing in the + initializer will be looked up in SCOPE. */ pop_p = push_scope (scope); /* Perform deferred access control checks, now that we know in which @@ -10682,17 +10687,12 @@ cp_parser_init_declarator (cp_parser* parser, if (cp_parser_attributes_opt (parser)) warning ("attributes after parenthesized initializer ignored"); - /* Leave the SCOPE, now that we have processed the initializer. It - is important to do this before calling cp_finish_decl because it - makes decisions about whether to create DECL_EXPRs or not based - on the current scope. */ - if (pop_p) - pop_scope (scope); - /* For an in-class declaration, use `grokfield' to create the declaration. */ if (member_p) { + if (pop_p) + pop_scope (scope); decl = grokfield (declarator, decl_specifiers, initializer, /*asmspec=*/NULL_TREE, /*attributes=*/NULL_TREE); @@ -10703,15 +10703,19 @@ cp_parser_init_declarator (cp_parser* parser, /* Finish processing the declaration. But, skip friend declarations. */ if (!friend_p && decl) - cp_finish_decl (decl, - initializer, - asm_specification, - /* If the initializer is in parentheses, then this is - a direct-initialization, which means that an - `explicit' constructor is OK. Otherwise, an - `explicit' constructor cannot be used. */ - ((is_parenthesized_init || !is_initialized) + { + cp_finish_decl (decl, + initializer, + asm_specification, + /* If the initializer is in parentheses, then this is + a direct-initialization, which means that an + `explicit' constructor is OK. Otherwise, an + `explicit' constructor cannot be used. */ + ((is_parenthesized_init || !is_initialized) ? 0 : LOOKUP_ONLYCONVERTING)); + if (pop_p) + pop_scope (DECL_CONTEXT (decl)); + } /* Remember whether or not variables were initialized by constant-expressions. */ -- cgit v1.2.1