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

            Bug ID: 118005
           Summary: Incorrect diagnostic combining [[gnu::noipa]] and
                    inline
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alx at kernel dot org
  Target Milestone: ---

Hi,

I use [[gnu::noipa]] in (C99) inline functions for the following reasons:

Within my library, the functions are inline, for an optimized library.
In the exported headers, I add the [[gnu::noipa]] attribute to the inline
functions, so that users don't get anything inline, which provides a strong
interface boundary, so that if any bugs are found in the library, fixing the
.so is enough, and the world doesn't need to be recompiled.

So, I provide inline definitions, but in the user code, a macro will add the
attribute to invalidate 'inline'.

This results in the following diagnostic:

$ gcc --version | head -n1
gcc (Debian 14.2.0-8) 14.2.0
$ cat inline.c 
[[gnu::noipa]] inline int f(void);

inline int f(void)
{
        return 42;
}
$ gcc -Wall -Wextra -S inline.c 
inline.c:1:27: warning: inline function ‘f’ given attribute ‘noinline’
[-Wattributes]
    1 | [[gnu::noipa]] inline int f(void);
      |                           ^
inline.c:4:1: warning: inline declaration of ‘f’ follows declaration with
attribute ‘noinline’ [-Wattributes]
    4 | {
      | ^
inline.c:1:27: note: previous declaration of ‘f’ with type ‘int(void)’
    1 | [[gnu::noipa]] inline int f(void);
      |                           ^


This diagnostic is wrong, because it thinks I'm using [[gnu::noinline]], while
I'm actually using [[gnu::noipa]].

Also, I would like to have a more precise know to disable this diagnostic,
without having to turn off the entire -Wattributes.  How about
-Wattributes-noinline-on-inline-func and/or -Wattributes-noipa-on-inline-func?

Or maybe just remove this diagnostic?  I don't think it's very useful.

Reply via email to