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

            Bug ID: 107166
           Summary: "useless type name in empty declaration" diagnostic
                    may refer to wrong location
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stephenheumann at gmail dot com
  Target Milestone: ---

GCC seems to give a "useless type name in empty declaration" diagnostic for any
empty declaration containing a type, but it always just points to the first
token of the declaration, which is not necessarily the type (or may only be a
part of it). E.g.:

static int;
_Alignas(int) char;
long long;

gives the following diagnostics:

<source>:1:1: warning: useless type name in empty declaration
    1 | static int;
      | ^~~~~~
<source>:2:1: warning: useless type name in empty declaration
    2 | _Alignas(int) char;
      | ^~~~~~~~
<source>:3:1: warning: useless type name in empty declaration
    3 | long long;
      | ^~~~

These could be changed to actually refer to the location of the type
specifier(s), or they could be changed to different diagnostics that already
exist for empty declarations without a type, such as "useless storage class
specifier in empty declaration".

Reply via email to