[Bug c/103104] missing warning about superfluous forward declaration -Wsuperfluous-forward-declaration

2021-12-16 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103104

Martin Sebor  changed:

   What|Removed |Added

   Last reconfirmed||2021-12-16
 CC||msebor at gcc dot gnu.org
 Status|UNCONFIRMED |NEW
 Blocks|87403   |
 Ever confirmed|0   |1
   Severity|normal  |enhancement

--- Comment #2 from Martin Sebor  ---
Based on the rather loose(*) description of -Wredundant-decls in the manual:

  Warn if anything is declared more than once in the same scope, even in cases
where multiple declaration is valid and changes nothing. 

I'd expect the warning to trigger but it doesn't, most likely because it only
triggers for the second and subsequent declaration that's not a definition.  It
seems that this can be viewed as a request to enhance -Wredundant-decls to do
what's already documented to do.

Here's a test case:

$ cat a.c && gcc -O2 -S -Wall -Wextra -Wredundant-decls a.c
static void f (void);
static void f (void);  // -Wredundant-decl
static void f (void) { }

static void g (void);  // no warning
static void g (void) { }

void h (void)
{
  f ();
  g ();
}

a.c:2:13: warning: redundant redeclaration of ‘f’ [-Wredundant-decls]
2 | static void f (void);  // -Wredundant-decl
  | ^
a.c:1:13: note: previous declaration of ‘f’ with type ‘void(void)’
1 | static void f (void);
  | ^

I say "loose" above because it suggests that the following should also be
diagnosed but aren't:

enum E;
enum E;  // missing -Wredundant-decl

struct S;
struct S;// missing -Wredundant-decl


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

[Bug c/103104] missing warning about superfluous forward declaration -Wsuperfluous-forward-declaration

2021-11-06 Thread egallager at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103104

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org
   Keywords||diagnostic
 Blocks||87403

--- Comment #1 from Eric Gallager  ---
-Wredundant-decls doesn't catch this?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning