public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors
@ 2003-09-11 14:54 Bruce at Fitzsimons dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not allowed in member function definition bangerth at dealii dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Bruce at Fitzsimons dot org @ 2003-09-11 14:54 UTC (permalink / raw)
To: gcc-bugs
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
Summary: __attribute__ not able to be placed on inline ctors
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Bruce at Fitzsimons dot org
CC: gcc-bugs at gcc dot gnu dot org
__attribute__ attributes are not able to be placed on inline ctors, which is a
bit frustrating.
Sometimes inline ctors are used in header files, esp. when doing a thin layer of
inheritance around an existing object ie only the base class needs
initialisation, there are no new member variables.
This is often the case for deriving exceptions, where a new type is desired (for
specific catch'es) but no new methods or members are defined.
A simple example (not the inheritance case)
class A
{
public:
A(int _anInt) __attribute__ ((deprecated)) { anInt = _anInt; }
private:
int anInt;
};
int main(void) {
A aInstance(42);
}
Fails to parse:
g++ test.cc
test.cc:4: syntax error before `{' token
test.cc:5: semicolon missing after declaration of `A'
test.cc: In function `int main()':
test.cc:10: no matching function for call to `A::A(int)'
test.cc:2: candidates are: A::A(const A&)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/12246] __attribute__ not able to be placed on inline ctors
2003-09-11 14:54 [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not allowed in member function definition bangerth at dealii dot org
@ 2003-09-11 14:54 ` Bruce at Fitzsimons dot org
2003-09-12 2:13 ` [Bug c++/12246] __attribute__ not allowed in member function definition Bruce at Fitzsimons dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Bruce at Fitzsimons dot org @ 2003-09-11 14:54 UTC (permalink / raw)
To: gcc-bugs
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
------- Additional Comments From Bruce at Fitzsimons dot org 2003-09-11 07:02 -------
I can provide a more realistic example, if required, or attach the test.cc if
copy/paste from the bug text is unacceptable.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/12246] __attribute__ not allowed in member function definition
2003-09-11 14:54 [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
@ 2003-09-11 14:54 ` bangerth at dealii dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2003-09-11 14:54 UTC (permalink / raw)
To: gcc-bugs
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 () {}
---------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/12246] __attribute__ not allowed in member function definition
2003-09-11 14:54 [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not allowed in member function definition bangerth at dealii dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
@ 2003-09-12 2:13 ` Bruce at Fitzsimons dot org
2003-09-12 2:16 ` Bruce at Fitzsimons dot org
2004-01-01 1:42 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: Bruce at Fitzsimons dot org @ 2003-09-12 2:13 UTC (permalink / raw)
To: gcc-bugs
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
------- Additional Comments From Bruce at Fitzsimons dot org 2003-09-12 02:13 -------
Yes, you're right Wolfgang, sorry I hadn't burrowed that far into it.
I've now seen some references to a patch for this
(http://gcc.gnu.org/ml/gcc-patches/2002-01/msg00223.html) but no indication that
it was accepted or went any further.
It is annoying that it doesn't always work, as this is a very useful feature in
mature software projects.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/12246] __attribute__ not allowed in member function definition
2003-09-11 14:54 [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
` (2 preceding siblings ...)
2003-09-12 2:13 ` [Bug c++/12246] __attribute__ not allowed in member function definition Bruce at Fitzsimons dot org
@ 2003-09-12 2:16 ` Bruce at Fitzsimons dot org
2004-01-01 1:42 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: Bruce at Fitzsimons dot org @ 2003-09-12 2:16 UTC (permalink / raw)
To: gcc-bugs
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
------- Additional Comments From Bruce at Fitzsimons dot org 2003-09-12 02:16 -------
(sorry for the spam)
In fact it does look like it was accepted (there is a followup) and the original
problem was slightly different, in that it parsed "...They [deprecated attribs]
were being properly handled by the grammar...".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/12246] __attribute__ not allowed in member function definition
2003-09-11 14:54 [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
` (3 preceding siblings ...)
2003-09-12 2:16 ` Bruce at Fitzsimons dot org
@ 2004-01-01 1:42 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-01 1:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-01-01 01:42 -------
Fixed for 3.4.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12246
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-01-01 1:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-11 14:54 [Bug c++/12246] New: __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not allowed in member function definition bangerth at dealii dot org
2003-09-11 14:54 ` [Bug c++/12246] __attribute__ not able to be placed on inline ctors Bruce at Fitzsimons dot org
2003-09-12 2:13 ` [Bug c++/12246] __attribute__ not allowed in member function definition Bruce at Fitzsimons dot org
2003-09-12 2:16 ` Bruce at Fitzsimons dot org
2004-01-01 1:42 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).