public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How do I deprecate a class?
@ 2007-03-21 13:59 Thimo.Neubauer
  2007-03-21 15:34 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Thimo.Neubauer @ 2007-03-21 13:59 UTC (permalink / raw)
  To: gcc-help

Hi!

I'd like to mark a class as deprecated, i.e. any instantiation or method
call should be warned. After reading

http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Type-Attributes.html#Type-Attributes

I concluded that

  class Foo {
  public:
	void  bar(int x);
  } __attribute__ ((deprecated));

should do the trick. However

  int main() {
	Foo f;

	return 0;
  };

only warns about the (obviously) unused variable but nothing else:

beachboys++ /tmp> make
g++ -Wall    foo.cc   -o foo
foo.cc: In function ‘int main()’:
foo.cc:11: warning: unused variable ‘f’
beachboys++ /tmp> g++ --version
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

Same effect with gcc 3.3 and 3.4. However a

  typedef Foo Quux __attribute__ ((deprecated));

with

  int main() {
	Quux f;

	return 0;
  };

does what I expected:

foo.cc: In function `int main()':
foo.cc:11: warning: `Quux' is deprecated (declared at foo.cc:8)
foo.cc:11: warning: unused variable `Quux f'

Did I understand anything wrong? Or is this a bug/feature? :-)

Please CC me on reply, I'm not subscribed to gcc-help.

Cheers
   Thimo

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How do I deprecate a class?
  2007-03-21 13:59 How do I deprecate a class? Thimo.Neubauer
@ 2007-03-21 15:34 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2007-03-21 15:34 UTC (permalink / raw)
  To: Thimo.Neubauer; +Cc: gcc-help

Thimo.Neubauer@cst.com writes:

> I concluded that
> 
>   class Foo {
>   public:
> 	void  bar(int x);
>   } __attribute__ ((deprecated));
> 
> should do the trick. However
> 
>   int main() {
> 	Foo f;
> 
> 	return 0;
>   };
> 
> only warns about the (obviously) unused variable but nothing else:

Looks like a bug to me.

And it's been filed already: http://gcc.gnu.org/PR16370

Interestingly, I do get a warning for this:

struct Foo { int i; } __attribute__ ((deprecated));
void foo() { struct Foo f; }

It matters whether I use "struct" or not.  Which is bizarre.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-21 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21 13:59 How do I deprecate a class? Thimo.Neubauer
2007-03-21 15:34 ` Ian Lance Taylor

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).