public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions
@ 2012-07-28 13:47 eggert at gnu dot org
  2012-08-14  4:08 ` [Bug c/54113] " eggert at gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: eggert at gnu dot org @ 2012-07-28 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54113
           Summary: -Wmissing-prototypes cries wolf for C99 inline
                    functions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: eggert@gnu.org


-Wmissing-prototypes produces false alarms for C99-style
inline functions.  Here's a simple example, taken from
<http://www.drdobbs.com/the-new-c-inline-functions/184401540>.
Suppose foo.h contains this:

  inline float square(float x) {return x*x;}
  inline float cube(float x) {return x*x*x;}

and foo.c contains this:

  #include "foo.h"
  extern float square(float x);
  extern float cube(float x);

Then the command:

  gcc -c -Wmissing-prototypes foo.c

outputs:

  In file included from foo.c:1:0:
  foo.h:1:14: warning: no previous prototype for 'square'
[-Wmissing-prototypes]
  foo.h:2:14: warning: no previous prototype for 'cube' [-Wmissing-prototypes]

The diagnostics should not be output, as this is the normal
way to use inline functions in C.

The simplest way to work around the problem is to avoid
the use of -Wmissing-prototypes, but that disables the
diagnostic for non-inline functions, where it's useful.

To fix this, I suggest that the diagnostic be suppressed
for inline functions, at least for C99 mode.


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

* [Bug c/54113] -Wmissing-prototypes cries wolf for C99 inline functions
  2012-07-28 13:47 [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions eggert at gnu dot org
@ 2012-08-14  4:08 ` eggert at gnu dot org
  2013-12-04 17:00 ` [Bug c/54113] -Wmissing-prototypes produces false alarms " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: eggert at gnu dot org @ 2012-08-14  4:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from eggert at gnu dot org 2012-08-14 04:08:17 UTC ---
In <http://lists.gnu.org/archive/html/bug-gnulib/2012-08/msg00038.html> Jim
Meyering reports that GCC 4.8.0 20120803 issues a different (but still bogus)
warning for this program.  It reports "error: no previous declaration for 'FOO' 
[-Werror=missing-declarations]" if FOO is an inline function.  This warning
should not be emitted either.


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

* [Bug c/54113] -Wmissing-prototypes produces false alarms for C99 inline functions
  2012-07-28 13:47 [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions eggert at gnu dot org
  2012-08-14  4:08 ` [Bug c/54113] " eggert at gnu dot org
@ 2013-12-04 17:00 ` mpolacek at gcc dot gnu.org
  2013-12-04 21:15 ` mpolacek at gcc dot gnu.org
  2013-12-04 21:18 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-12-04 17:00 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-12-04
                 CC|                            |mpolacek at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I have a patch for disabling the diagnostic  for inline functions in C99 mode.


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

* [Bug c/54113] -Wmissing-prototypes produces false alarms for C99 inline functions
  2012-07-28 13:47 [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions eggert at gnu dot org
  2012-08-14  4:08 ` [Bug c/54113] " eggert at gnu dot org
  2013-12-04 17:00 ` [Bug c/54113] -Wmissing-prototypes produces false alarms " mpolacek at gcc dot gnu.org
@ 2013-12-04 21:15 ` mpolacek at gcc dot gnu.org
  2013-12-04 21:18 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-12-04 21:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Wed Dec  4 21:15:31 2013
New Revision: 205680

URL: http://gcc.gnu.org/viewcvs?rev=205680&root=gcc&view=rev
Log:
    PR c/54113
c/
    * c-decl.c (start_function): Don't warn for missing prototype for
    inline functions.
testsuite/
    * gcc.dg/pr54113.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr54113.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c/54113] -Wmissing-prototypes produces false alarms for C99 inline functions
  2012-07-28 13:47 [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions eggert at gnu dot org
                   ` (2 preceding siblings ...)
  2013-12-04 21:15 ` mpolacek at gcc dot gnu.org
@ 2013-12-04 21:18 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-12-04 21:18 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk.


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

end of thread, other threads:[~2013-12-04 21:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-28 13:47 [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions eggert at gnu dot org
2012-08-14  4:08 ` [Bug c/54113] " eggert at gnu dot org
2013-12-04 17:00 ` [Bug c/54113] -Wmissing-prototypes produces false alarms " mpolacek at gcc dot gnu.org
2013-12-04 21:15 ` mpolacek at gcc dot gnu.org
2013-12-04 21:18 ` mpolacek 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).