This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81830] New: missing Wunused-local-typedef on a typedef of an unnamed enum or struct


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81830

            Bug ID: 81830
           Summary: missing Wunused-local-typedef on a typedef of an
                    unnamed enum or struct
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC (in C mode) correctly diagnoses the unused typedefs in each of the two
functions below.  G++, however, only diagnoses those in f and misses those in
g.  Clang diagnoses all of them in both modes.

$ cat x.c && gcc -O2 -S -Wall -Wextra -Wpedantic -Wunused -xc++ x.c
void f (void)
{
  typedef enum E { e } F;          // -Wunused-local-typedefs
  typedef struct A { int i; } B;   // ditto
}

void g (void)
{
  typedef enum { e } F;          // missing -Wunused-local-typedefs in C++
  typedef struct { int i; } B;   // ditto
}
x.c: In function ‘void f()’:
x.c:3:24: warning: typedef ‘F’ locally defined but not used
[-Wunused-local-typedefs]
   typedef enum E { e } F;          // -Wunused-local-typedefs
                        ^
x.c:4:31: warning: typedef ‘B’ locally defined but not used
[-Wunused-local-typedefs]
   typedef struct A { int i; } B;   // ditto
                               ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]