aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r--gcc/cp/parser.cc46
1 files changed, 34 insertions, 12 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 8284d65..0578aad 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -24101,8 +24101,26 @@ cp_parser_init_declarator (cp_parser* parser,
/* Enter the newly declared entry in the symbol table. If we're
processing a declaration in a class-specifier, we wait until
- after processing the initializer. */
- if (!member_p)
+ after processing the initializer, except for static data members
+ initialized here. */
+ if (member_p)
+ {
+ if (scope)
+ /* Enter the SCOPE. That way unqualified names appearing in the
+ initializer will be looked up in SCOPE. */
+ pushed_scope = push_scope (scope);
+
+ if (is_initialized
+ && decl_specifiers->storage_class == sc_static
+ && !function_declarator_p (declarator))
+ {
+ tree all_attrs = attr_chainon (attributes, prefix_attributes);
+ decl = start_initialized_static_member (declarator,
+ decl_specifiers,
+ all_attrs);
+ }
+ }
+ else
{
if (parser->in_unbraced_linkage_specification_p)
decl_specifiers->storage_class = sc_extern;
@@ -24119,10 +24137,6 @@ cp_parser_init_declarator (cp_parser* parser,
&& DECL_SOURCE_LOCATION (decl) == input_location)
DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
}
- else if (scope)
- /* Enter the SCOPE. That way unqualified names appearing in the
- initializer will be looked up in SCOPE. */
- pushed_scope = push_scope (scope);
/* Perform deferred access control checks, now that we know in which
SCOPE the declared entity resides. */
@@ -24185,7 +24199,7 @@ cp_parser_init_declarator (cp_parser* parser,
bool has_lambda_scope = false;
if (decl != error_mark_node
- && !member_p
+ && decl
&& (processing_template_decl || DECL_NAMESPACE_SCOPE_P (decl)))
has_lambda_scope = true;
@@ -24235,10 +24249,14 @@ cp_parser_init_declarator (cp_parser* parser,
pop_scope (pushed_scope);
pushed_scope = NULL_TREE;
}
- decl = grokfield (declarator, decl_specifiers,
- initializer, !is_non_constant_init,
- /*asmspec=*/NULL_TREE,
- attr_chainon (attributes, prefix_attributes));
+ if (decl)
+ finish_initialized_static_member (decl, initializer,
+ /*asmspec=*/NULL_TREE);
+ else
+ decl = grokfield (declarator, decl_specifiers,
+ initializer, !is_non_constant_init,
+ /*asmspec=*/NULL_TREE,
+ attr_chainon (attributes, prefix_attributes));
if (decl && TREE_CODE (decl) == FUNCTION_DECL)
cp_parser_save_default_args (parser, decl);
cp_finalize_omp_declare_simd (parser, decl);
@@ -33765,7 +33783,11 @@ cp_parser_template_declaration_after_parameters (cp_parser* parser,
}
/* Register member declarations. */
- if (member_p && !friend_p && decl && !DECL_CLASS_TEMPLATE_P (decl))
+ if (member_p && !friend_p && decl && !DECL_CLASS_TEMPLATE_P (decl)
+ /* But this is not needed for initialised static members, that were
+ registered in start_initialized_static_member to be able to be used
+ in their own definition. */
+ && !is_static_data_member_initialized_in_class (decl))
finish_member_declaration (decl);
/* If DECL is a function template, we must return to parse it later.
(Even though there is no definition, there might be default