aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Butcher <adam@jessamine.co.uk>2013-09-23 23:43:34 +0100
committerAdam Butcher <abutcher@gcc.gnu.org>2013-09-23 23:43:34 +0100
commit7a9a6e244936e62fb9889237331ae324a0638f0e (patch)
treef06174c362e3cdbe00ad92584ca3495046955167
parent1a4109b68586ceb6c852cb6c405967ff084b7800 (diff)
downloadgcc-7a9a6e244936e62fb9889237331ae324a0638f0e.zip
gcc-7a9a6e244936e62fb9889237331ae324a0638f0e.tar.gz
gcc-7a9a6e244936e62fb9889237331ae324a0638f0e.tar.bz2
Fix instantiation of implicit function template forward declarations.
* parser.c (cp_parser_init_declarator): Defer calling finish_fully_implicit_template for forward declarations until after other decl processing is complete. Cleanup for clarity: Extract 'else' case after 'if' containing unconditional return. From-SVN: r202850
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c79
2 files changed, 49 insertions, 37 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 156dea2..380fae9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2013-09-23 Adam Butcher <adam@jessamine.co.uk>
+ * parser.c (cp_parser_init_declarator): Defer calling
+ finish_fully_implicit_template for forward declarations until after
+ other decl processing is complete. Cleanup for clarity: Extract 'else'
+ case after 'if' containing unconditional return.
+
+2013-09-23 Adam Butcher <adam@jessamine.co.uk>
+
* parser.c (make_generic_type_name): Spell generic type names '<autoN>'
rather than '__GenN'.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 82abf7c..f3133f3 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16318,47 +16318,43 @@ cp_parser_init_declarator (cp_parser* parser,
"a function-definition is not allowed here");
return error_mark_node;
}
- else
- {
- location_t func_brace_location
- = cp_lexer_peek_token (parser->lexer)->location;
-
- /* Neither attributes nor an asm-specification are allowed
- on a function-definition. */
- if (asm_specification)
- error_at (asm_spec_start_token->location,
- "an asm-specification is not allowed "
- "on a function-definition");
- if (attributes)
- error_at (attributes_start_token->location,
- "attributes are not allowed "
- "on a function-definition");
- /* This is a function-definition. */
- *function_definition_p = true;
-
- /* Parse the function definition. */
- if (member_p)
- decl = cp_parser_save_member_function_body (parser,
- decl_specifiers,
- declarator,
- prefix_attributes);
- else
- decl =
- (cp_parser_function_definition_from_specifiers_and_declarator
- (parser, decl_specifiers, prefix_attributes, declarator));
- if (decl != error_mark_node && DECL_STRUCT_FUNCTION (decl))
- {
- /* This is where the prologue starts... */
- DECL_STRUCT_FUNCTION (decl)->function_start_locus
- = func_brace_location;
- }
+ location_t func_brace_location
+ = cp_lexer_peek_token (parser->lexer)->location;
- return decl;
+ /* Neither attributes nor an asm-specification are allowed
+ on a function-definition. */
+ if (asm_specification)
+ error_at (asm_spec_start_token->location,
+ "an asm-specification is not allowed "
+ "on a function-definition");
+ if (attributes)
+ error_at (attributes_start_token->location,
+ "attributes are not allowed "
+ "on a function-definition");
+ /* This is a function-definition. */
+ *function_definition_p = true;
+
+ /* Parse the function definition. */
+ if (member_p)
+ decl = cp_parser_save_member_function_body (parser,
+ decl_specifiers,
+ declarator,
+ prefix_attributes);
+ else
+ decl =
+ (cp_parser_function_definition_from_specifiers_and_declarator
+ (parser, decl_specifiers, prefix_attributes, declarator));
+
+ if (decl != error_mark_node && DECL_STRUCT_FUNCTION (decl))
+ {
+ /* This is where the prologue starts... */
+ DECL_STRUCT_FUNCTION (decl)->function_start_locus
+ = func_brace_location;
}
+
+ return decl;
}
- else if (parser->fully_implicit_function_template_p)
- decl = finish_fully_implicit_template (parser, decl);
}
/* [dcl.dcl]
@@ -16581,6 +16577,15 @@ cp_parser_init_declarator (cp_parser* parser,
if (!friend_p && pushed_scope)
pop_scope (pushed_scope);
+ if (function_declarator_p (declarator)
+ && parser->fully_implicit_function_template_p)
+ {
+ if (member_p)
+ decl = finish_fully_implicit_template (parser, decl);
+ else
+ finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+ }
+
return decl;
}