From 657e4e47344408f7ca6b3c05bd86337dd424a3cf Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 2 Dec 2015 08:33:06 +0100 Subject: [PATCH] =?utf8?q?re=20PR=20c/68533=20(bogus=20location=20for=20"w?= =?utf8?q?arning:=20=E2=80=98struct=20s3=E2=80=99=20declared=20inside=20pa?= =?utf8?q?rameter=20list=20will=20not=20be=20visible=20outside=20of=20this?= =?utf8?q?=20definition=20or=20declaration")?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PR c/68533 * c-decl.c (get_parm_info): Use b->locus instead of input_location for diagnostics. * gcc.dg/pr68533.c: New test. From-SVN: r231147 --- gcc/c/ChangeLog | 6 +++ gcc/c/c-decl.c | 13 ++++--- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/pr68533.c | 68 ++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr68533.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 43d1579aff6..acb8ee4e6cc 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-12-02 Jakub Jelinek + + PR c/68533 + * c-decl.c (get_parm_info): Use b->locus instead of input_location + for diagnostics. + 2015-12-01 Julian Brown Cesar Philippidis James Norris diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 31de0a51e56..efb0a52c9c4 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -6913,11 +6913,11 @@ get_parm_info (bool ellipsis, tree expr) { if (TYPE_QUALS (TREE_TYPE (b->decl)) != TYPE_UNQUALIFIED || C_DECL_REGISTER (b->decl)) - error ("% as only parameter may not be qualified"); + error_at (b->locus, "% as only parameter may not be qualified"); /* There cannot be an ellipsis. */ if (ellipsis) - error ("% must be the only parameter"); + error_at (b->locus, "% must be the only parameter"); arg_info->types = void_list_node; return arg_info; @@ -6946,13 +6946,14 @@ get_parm_info (bool ellipsis, tree expr) /* Check for forward decls that never got their actual decl. */ if (TREE_ASM_WRITTEN (decl)) - error ("parameter %q+D has just a forward declaration", decl); + error_at (b->locus, + "parameter %q+D has just a forward declaration", decl); /* Check for (..., void, ...) and issue an error. */ else if (VOID_TYPE_P (type) && !DECL_NAME (decl)) { if (!gave_void_only_once_err) { - error ("% must be the only parameter"); + error_at (b->locus, "% must be the only parameter"); gave_void_only_once_err = true; } } @@ -6991,13 +6992,13 @@ get_parm_info (bool ellipsis, tree expr) { if (b->id) /* The %s will be one of 'struct', 'union', or 'enum'. */ - warning_at (input_location, 0, + warning_at (b->locus, 0, "%<%s %E%> declared inside parameter list" " will not be visible outside of this definition or" " declaration", keyword, b->id); else /* The %s will be one of 'struct', 'union', or 'enum'. */ - warning_at (input_location, 0, + warning_at (b->locus, 0, "anonymous %s declared inside parameter list" " will not be visible outside of this definition or" " declaration", keyword); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3363c9506b4..da31935c269 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-02 Jakub Jelinek + + PR c/68533 + * gcc.dg/pr68533.c: New test. + 2015-12-01 Richard Sandiford PR tree-optimization/68577 diff --git a/gcc/testsuite/gcc.dg/pr68533.c b/gcc/testsuite/gcc.dg/pr68533.c new file mode 100644 index 00000000000..e1a1f31f65a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68533.c @@ -0,0 +1,68 @@ +/* PR c/68533 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct T { int t; }; + +void +f1 ( + struct S * /* { dg-warning "declared inside parameter list will not be visible outside of this definition or declaration" } */ + x, + struct T * + y + ) +{ + y->t = 4; +} + +void +f2 ( + struct {int s;} * /* { dg-warning "anonymous struct declared inside parameter list will not be visible outside of this definition or declaration" } */ + x, + struct T * + y + ) +{ + y->t = 5; +} + +void +f3 ( + const void + ) /* { dg-error "'void' as only parameter may not be qualified" } */ +{ +} + +void +f4 ( + void, /* { dg-error "'void' must be the only parameter" } */ + ... + ) +{ +} + +void +f5 ( + int + x; /* { dg-error "parameter 'x' has just a forward declaration" } */ + int y + ) +{ +} + +void +f6 ( + int + x, + void + ) /* { dg-error "'void' must be the only parameter" } */ +{ +} + +void +f7 ( + void, /* { dg-error "'void' must be the only parameter" } */ + int y + ) +{ +} -- 2.30.2