This is the mail archive of the gcc-bugs@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]

[Bug c++/12246] __attribute__ not allowed in member function definition


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12246


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2003-09-11 14:06:28
               date|                            |
            Summary|__attribute__ not able to be|__attribute__ not allowed in
                   |placed on inline ctors      |member function definition


------- Additional Comments From bangerth at dealii dot org  2003-09-11 14:06 -------
Indeed, but this has nothing to do with constructors, as this example shows: 
------------------------------------------------------ 
struct A { 
    int f()  __attribute__ ((deprecated)) {} 
}; 
 
int f()  __attribute__ ((deprecated)) {} 
------------------------------------------------------- 
Compiled with 3.3, we get 
mp/g> ~/bin/gcc-3.3/bin/c++ -c x.cc 
x.cc:2: error: parse error before `{' token 
x.cc:2: error: missing ';' before right brace 
x.cc:5: error: parse error before `{' token 
 
That's not very enlightening. Present mainline tells us more, at least for the 
non-member case: 
mp/g> c++ -c x.cc 
x.cc:2: error: expected function-definition 
x.cc:5: error: attributes are not allowed on a function-definition 
 
So the point is really that attributes are not allowed at function _definitions_ (though it's 
easy to check that they are of course allowed at _declarations_), but that this is only 
properly diagnosed for the non-member case. 
 
W. 
 
PS: A workaround for the original problem is this: 
-------------------- 
struct A { 
    A()  __attribute__ ((deprecated)); 
}; 
 
inline A::A () {} 
---------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]