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

            Bug ID: 63877
           Summary: - -Wmissing-declarations produces false alarms for C99
                    inline functions
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at gnu dot org

This is a followup to PR c/54113, which was about -Wmissing-prototypes.  This
followup bug report is the same, except it is about -Wmissing-declarations.

-Wmissing-declarations produces false alarms for C99-style
inline functions.  We can use the same example as for PR c/54113.
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-declarations foo.c

outputs:

  In file included from foo.c:1:0:
  foo.h:1:14: warning: no previous declaration for 'square'
[-Wmissing-declarations]
   inline float square(float x) {return x*x;}
              ^
  foo.h:2:14: warning: no previous declaration for 'cube'
[-Wmissing-declarations]
   inline float cube(float x) {return x*x*x;}
              ^

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

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

Reply via email to