This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

always_inline and attribute placement on functions


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]