public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107166] New: "useless type name in empty declaration" diagnostic may refer to wrong location
@ 2022-10-06  0:54 stephenheumann at gmail dot com
  2022-10-06  4:08 ` [Bug c/107166] " pinskia at gcc dot gnu.org
  2022-10-06  4:10 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: stephenheumann at gmail dot com @ 2022-10-06  0:54 UTC (permalink / raw)
  To: gcc-bugs

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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/107166] "useless type name in empty declaration" diagnostic may refer to wrong location
  2022-10-06  0:54 [Bug c/107166] New: "useless type name in empty declaration" diagnostic may refer to wrong location stephenheumann at gmail dot com
@ 2022-10-06  4:08 ` pinskia at gcc dot gnu.org
  2022-10-06  4:10 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-06  4:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/107166] "useless type name in empty declaration" diagnostic may refer to wrong location
  2022-10-06  0:54 [Bug c/107166] New: "useless type name in empty declaration" diagnostic may refer to wrong location stephenheumann at gmail dot com
  2022-10-06  4:08 ` [Bug c/107166] " pinskia at gcc dot gnu.org
@ 2022-10-06  4:10 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-06  4:10 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-10-06
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |4.7.1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. The C++ front-end does a better job here.
Though gets the last one wrong:

<source>:3:6: error: declaration does not declare anything [-fpermissive]
    3 | long long;
      |      ^~~~


clang does even better job and underlines all parts:
<source>:1:1: warning: declaration does not declare anything
[-Wmissing-declarations]
static int;
^~~~~~~~~~
<source>:2:1: warning: declaration does not declare anything
[-Wmissing-declarations]
_Alignas(int) char;
^~~~~~~~~~~~~~~~~~
<source>:3:1: warning: declaration does not declare anything
[-Wmissing-declarations]
long long;
^~~~~~~~~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-06  4:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06  0:54 [Bug c/107166] New: "useless type name in empty declaration" diagnostic may refer to wrong location stephenheumann at gmail dot com
2022-10-06  4:08 ` [Bug c/107166] " pinskia at gcc dot gnu.org
2022-10-06  4:10 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).