re PR c++/28560 (Trouble with __attribute__ in template parameter)

PR c++/28560
        * decl.c (groktypename): Also ignore attributes on dependent
        possibly-class types.

From-SVN: r131755
This commit is contained in:
Jason Merrill 2008-01-23 00:11:58 -05:00 committed by Jason Merrill
parent 62b445b31c
commit b2a7def5ab
3 changed files with 18 additions and 2 deletions

View File

@ -9,6 +9,10 @@
2008-01-22 Jason Merrill <jason@redhat.com>
PR c++/28560
* decl.c (groktypename): Also ignore attributes on dependent
possibly-class types.
PR c++/34912
* friend.c (do_friend): Check for prior declaration of a friend
function of a local class.

View File

@ -3908,8 +3908,12 @@ groktypename (cp_decl_specifier_seq *type_specifiers,
if (attrs)
{
if (CLASS_TYPE_P (type))
warning (OPT_Wattributes, "ignoring attributes applied to class type "
"outside of definition");
warning (OPT_Wattributes, "ignoring attributes applied to class type %qT "
"outside of definition", type);
else if (IS_AGGR_TYPE (type))
/* A template type parameter or other dependent type. */
warning (OPT_Wattributes, "ignoring attributes applied to dependent "
"type %qT without an associated declaration", type);
else
cplus_decl_attributes (&type, attrs, 0);
}

View File

@ -0,0 +1,8 @@
// PR c++/28560
template<typename> struct A {};
template<int> struct B;
template<int N> struct C :
A<typename B<N>::X __attribute__((unused))> {}; // { dg-warning "attribute" }