aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-05-01 07:40:26 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-05-01 07:40:26 +0000
commitae5ebda47370113e4f5f58fe23dea8c257eee9e0 (patch)
tree6f043bfee7407e15268b1ee456105c8ea3e3ea45 /gcc/c
parent96b40f8d4c5288483a72676796154b82f92d6c8c (diff)
downloadgcc-ae5ebda47370113e4f5f58fe23dea8c257eee9e0.zip
gcc-ae5ebda47370113e4f5f58fe23dea8c257eee9e0.tar.gz
gcc-ae5ebda47370113e4f5f58fe23dea8c257eee9e0.tar.bz2
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
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c14
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 8cc268b..a5b4f5f 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,11 @@
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.
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 56f79f6..c22c4ab 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -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;