Commit ae5ebda4 by Marek Polacek Committed by Marek Polacek

re PR c/60915 (confusing diagnostic from attribute on function definition)

	PR c/60915
	* c-parser.c (c_parser_declaration_or_fndef): Give better error if
	function-definition has an attribute after the declarator.

	* gcc.dg/pr60915.c: New test.

From-SVN: r209975
parent 96b40f8d
2014-05-01 Marek Polacek <polacek@redhat.com>
PR c/60915
* c-parser.c (c_parser_declaration_or_fndef): Give better error if
function-definition has an attribute after the declarator.
2014-05-01 Marek Polacek <polacek@redhat.com>
PR c/60257
* c-typeck.c (warning_init): Add location_t parameter. Call
warning_at instead of warning.
......
......@@ -1688,7 +1688,19 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
if (c_parser_next_token_is_keyword (parser, RID_ASM))
asm_name = c_parser_simple_asm_expr (parser);
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
postfix_attrs = c_parser_attributes (parser);
{
postfix_attrs = c_parser_attributes (parser);
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
{
/* This means there is an attribute specifier after
the declarator in a function definition. Provide
some more information for the user. */
error_at (here, "attributes should be specified before the "
"declarator in a function definition");
c_parser_skip_to_end_of_block_or_statement (parser);
return;
}
}
if (c_parser_next_token_is (parser, CPP_EQ))
{
tree d;
......
2014-05-01 Marek Polacek <polacek@redhat.com>
PR c/60915
* gcc.dg/pr60915.c: New test.
2014-05-01 Marek Polacek <polacek@redhat.com>
PR c/60257
* gcc.dg/pr60257.c: New test.
......
/* PR c/60915 */
/* { dg-do compile } */
void /* { dg-error "attributes should be specified before the declarator in a function definition" } */
foo (void) __attribute__((__visibility__("default")))
{
}
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