This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15269] New: __attribute__((deprecated)) broken with inline, ignored with pure virtual, misreported after definition
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 May 2004 18:08:56 -0000
- Subject: [Bug c++/15269] New: __attribute__((deprecated)) broken with inline, ignored with pure virtual, misreported after definition
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The __attribute__((deprecated)):
* cannot be used with inline methods [or: the info needs to say how to do so]
I get a parser error if I put it in the obvious place
* is ignored when used with a pure virtual method (though I'm pleased to see
it does get inherited - if I change hook's type to Derived* I *do* get
my warning, even without the attribute overtly on Derived::Virtue)
* gets a report referencing the *definition* rather than the
*declaration* (as advertised) if the method is used after its definition.
Environment:
System: Linux whorl 2.4.18-1-686-smp #1 SMP Sun Feb 1 04:12:27 MST 2004 i686 GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
How-To-Repeat:
* Save the following to a file named deprecate.cpp; make deprecated
will then compile it (see comment at end recording output).
Observe that the use of Virtue gets no warning.
Observe that second warning for Method() references defn, not decl.
* Uncomment the attribute on Inline, make deprecated, see parser error.
It is possible to get round this; declare it with attribute in the
class body, then have a separate
inline int Base::Inline() { return 0; }
after the class body.
class Base {
public:
virtual int Virtue() __attribute__((deprecated)) = 0;
int Inline() // __attribute__((deprecated)) // causes parser error
{ return 0; }
int Method() __attribute__((deprecated)); // declaration
};
class Derived : public Base {
/* Adding __attribute__((deprecated)) to this makes no difference, but
* that's sensible enough: */
int Virtue();
};
int Derived::Virtue() { return Method(); } // warning correctly references declaration
int Base::Method() { return 42; } // definition
int main(void) {
Derived obj;
Base *hook = &obj;
return hook->Virtue() // no warning about Virtue !
+ hook->Method(); // warning references definition, not declaration
}
/*
make -k deprecate CXXFLAGS=-fmessage-length=0
g++ -fmessage-length=0 deprecate.cpp -o deprecate
deprecate.cpp: In member function `virtual int Derived::Virtue()':
deprecate.cpp:14: warning: `Method' is deprecated (declared at deprecate.cpp:6)
deprecate.cpp: In function `int main()':
deprecate.cpp:21: warning: `Method' is deprecated (declared at deprecate.cpp:15)
*/
------- Additional Comments From eddy at opera dot com 2004-05-03 18:08 -------
Fix:
Not known.
--
Summary: __attribute__((deprecated)) broken with inline, ignored
with pure virtual, misreported after definition
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eddy at opera dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15269