public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51676] New: -Wsuggest-attribute={pure,const} should give line number of declaration, not definition
@ 2011-12-25  6:06 b.r.longbons at gmail dot com
  2011-12-30  6:35 ` [Bug c/51676] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: b.r.longbons at gmail dot com @ 2011-12-25  6:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51676

             Bug #: 51676
           Summary: -Wsuggest-attribute={pure,const} should give line
                    number of declaration, not definition
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: b.r.longbons@gmail.com


Created attachment 26184
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26184
minimal testcase for both attributes

Although it's obvious why GCC does what it does, it would be much more useful
if these warnings would give the location at which the attribute would be
added.

Expected result:
Warnings at the (first) declaration. In attached testcase, on lines 2 and 3
(which would usually be in a header file).

Actual result:
Warnings at the definition. In testcase, on lines 4 and 5 (which are usually in
the implementation file).

Tested with: 4.6.0, 4.6.1, 4.6.2, and trunk r182496


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

* [Bug c/51676] -Wsuggest-attribute={pure,const} should give line number of declaration, not definition
  2011-12-25  6:06 [Bug c/51676] New: -Wsuggest-attribute={pure,const} should give line number of declaration, not definition b.r.longbons at gmail dot com
@ 2011-12-30  6:35 ` pinskia at gcc dot gnu.org
  2012-01-02 10:49 ` rguenth at gcc dot gnu.org
  2012-01-02 20:27 ` b.r.longbons at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-30  6:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51676

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-30 06:33:44 UTC ---
Not all places have both a definition and a declaration.  Also we merge the
definition and the declaration giving the DECL internally as just the
definition's location.


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

* [Bug c/51676] -Wsuggest-attribute={pure,const} should give line number of declaration, not definition
  2011-12-25  6:06 [Bug c/51676] New: -Wsuggest-attribute={pure,const} should give line number of declaration, not definition b.r.longbons at gmail dot com
  2011-12-30  6:35 ` [Bug c/51676] " pinskia at gcc dot gnu.org
@ 2012-01-02 10:49 ` rguenth at gcc dot gnu.org
  2012-01-02 20:27 ` b.r.longbons at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-02 10:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51676

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-02
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-02 10:48:54 UTC ---
Yeah, it's pretty difficult (read: impossible) to implement.  Consider
multiple declarations as well ...


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

* [Bug c/51676] -Wsuggest-attribute={pure,const} should give line number of declaration, not definition
  2011-12-25  6:06 [Bug c/51676] New: -Wsuggest-attribute={pure,const} should give line number of declaration, not definition b.r.longbons at gmail dot com
  2011-12-30  6:35 ` [Bug c/51676] " pinskia at gcc dot gnu.org
  2012-01-02 10:49 ` rguenth at gcc dot gnu.org
@ 2012-01-02 20:27 ` b.r.longbons at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: b.r.longbons at gmail dot com @ 2012-01-02 20:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51676

--- Comment #3 from Ben Longbons <b.r.longbons at gmail dot com> 2012-01-02 20:27:41 UTC ---
I'm not familiar with GCC internals, but would it be as easy as adding and
using a second field for "first declaration"?

If the first (possibly only) declaration is the definition, then just remember
it.

If there are one or more declarations before the definition, then just remember
the first one.


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

end of thread, other threads:[~2012-01-02 20:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-25  6:06 [Bug c/51676] New: -Wsuggest-attribute={pure,const} should give line number of declaration, not definition b.r.longbons at gmail dot com
2011-12-30  6:35 ` [Bug c/51676] " pinskia at gcc dot gnu.org
2012-01-02 10:49 ` rguenth at gcc dot gnu.org
2012-01-02 20:27 ` b.r.longbons at gmail dot com

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