Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 33911
Product:  
Component:  
Status: NEW
Resolution:
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Benjamin Kosnik <bkoz@gcc.gnu.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 33911 depends on: Show dependency tree
Show dependency graph
Bug 33911 blocks:

Additional Comments:





Mark bug as waiting for feedback
Mark bug as suspended




View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-05-02 21:41 Opened: 2007-10-26 15:08
In the following example, class "foo" gets a deprecated warning, but a similar
class template "goo" does not. Typedefs constructed with foo or goo get an
error.

What up?


struct foo
{
  int i;
} __attribute__ ((__deprecated__));

template<typename _Tp>
struct goo
{
  int i;
} __attribute__ ((__deprecated__));

typedef foo foo_type __attribute__ ((__deprecated__));
typedef goo<int> goo_type __attribute__ ((__deprecated__));


int main()
{
  foo f1;
  goo<int> f2;

  foo_type f3;
  goo_type f4;

  return 0;
}


I have a patch to mark the C++0x bits deprecated, but it's not working because
of this issue.

------- Comment #1 From Paolo Carlini 2007-10-26 16:08 -------
*** Bug 33912 has been marked as a duplicate of this bug. ***

------- Comment #2 From niemayer@isg.de 2007-12-20 14:32 -------
I can second that problem for template member functions - in contrast to
non-template member functions, where the attribute works.

This gives a warning about deprecation as expected:
-----------------------------------------------------------------
struct T { } ;

struct A {
        inline void foo(T & ) __attribute__((deprecated));
};

inline void A::foo(T & ) { }

void test(T & t) {
        A a;
        a.foo(t);
}
-------------------------------------------------------------

... while this is not causing a warning as it should:
-------------------------------------------------------------
struct A {
        template <class T> inline void foo(T & ) __attribute__((deprecated));
};

template <class T> inline void A::foo(T & ) { }

void test(A & t) {
        A a;
        a.foo(t);
}
-------------------------------------------------------------

------- Comment #3 From Jason Merrill 2008-01-04 22:23 -------
Subject: Re:  attribute deprecated vs. templates

niemayer at isg dot de wrote:
> I can second that problem for template member functions - in contrast to
> non-template member functions, where the attribute works.

This is a parser bug: parsing the member template declaration winds up 
in cp_parser_init_declarator, which ignores attributes at the end of a 
declaration.  A normal member function goes through 
cp_parser_member_declaration, which handles the attributes properly. 
You can work around this bug by moving the attribute into the 
decl-specifier-seq, i.e. "void __attribute ((deprecated)) foo(T&)".

Jason

------- Comment #4 From Andrew Pinski 2008-12-28 03:17 -------
*** Bug 36307 has been marked as a duplicate of this bug. ***

------- Comment #5 From Jason Merrill 2009-11-05 23:08 -------
Not planning to work on this soon since there's a reasonable workaround.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug