[Bug c/81568] attribute always_inline honored even after attribute noinline

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 7 21:26:00 GMT 2017


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
      Known to fail|                            |5.4.0, 6.4.0, 7.2.0

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thanks for the ping!  I just committed a fix for pr81544 (and pr81566) that
makes attribute validation more consistent.  With the patch applied, the output
for the test case in comment #0 is as follows.  There's just one warning and no
error because (as the warning says) the conflicting attribute is dropped.

I think with that this bug can be resolved as fixed as well (I forgot about it
and so didn't mention it in the commit).  Let me go ahead and do that, but
please feel free to take the freshly committed patch for a spin and open new
bugs if/when you find them or if you have suggestions for further refinements
or enhancements in this area.

$ cat z.c && gcc -O2 -S -Wall -Wextra -Wpedantic z.c
int __attribute__ ((noinline)) f (int);
int __attribute__ ((always_inline)) f (int);

int f (int i) { return i > 1 ? i * f (i - 1) * f (i - 2) : i > 0 ? i * f (i -
1) : 1; }

int f1 (void)
{
  return f (123);
}
z.c:2:1: warning: ignoring attribute ‘always_inline’ because it conflicts with
attribute ‘noinline’ [-Wattributes]
 int __attribute__ ((always_inline)) f (int);
 ^~~
z.c:1:32: note: previous declaration here
 int __attribute__ ((noinline)) f (int);
                                ^


More information about the Gcc-bugs mailing list