Re: always_inline and attribute placement on functions

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

 



2013/9/5 Jonathan Wakely <jwakely.gcc@xxxxxxxxx>:
>
> 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.

I am not sure it is relevant but, if I understand correctly,
given that a C source with a function definition and
three locations <X>, <Y>, and <Z>:

<X> void <Y> f () <Z>
{ ... }

you cannot place attribute at location <Z> because the C front end
may confuse attribute with old style C function definition:

void f (a, b)
  int a;
  int b;
{ ... }

(But for the declaration: <X> void <Y> f () <Z>;
 All three locations are ok to use attribute.)

If the C++ front end parser uses some common parts of
C front end implementation, could it be a possible cause
having such misleading diagnostic?


Best regards,
jasonwucj




[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