always_inline and attribute placement on functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a sort of follow-up to
http://gcc.gnu.org/ml/gcc-help/2007-01/msg00049.html

The docs for the always_inline attribute at
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html say:

"For functions declared inline, this attribute inlines the function
even if no optimization level is specified."

But testing and Ian's mail at
http://gcc.gnu.org/ml/gcc-help/2007-01/msg00051.html say that you
don't need the "inline" keyword on an "always_inline" function.
Should the docs be clarified?


For this code:
$ cat b.cc
inline void f() __attribute((always_inline)) { }

$ g++ -std=gnu++0x b.cc -Wall -c -O3
b.cc:1:17: error: attributes are not allowed on a function-definition
$

However, moving the attribute shows that actually it is allowed:

$ cat b.cc
inline __attribute((always_inline)) void f() { }

$ g++ -std=gnu++0x b.cc -Wall -c -O3
$

If placing the attribute at that location is valid then the wording of
the diagnostic is misleading, at best.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux