commit 025530d086fe52c9c7c5e697ec20480a0ebd6bea Author: Jason Merrill Date: Tue Nov 11 10:58:54 2014 -0500 PR c++/33911 * decl2.c (is_late_template_attribute): Attribute deprecated is not deferred. * pt.c (lookup_template_class_1): Copy TREE_DEPRECATED. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index ff40710..c18cd1e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1204,9 +1204,9 @@ is_late_template_attribute (tree attr, tree decl) /* Also defer most attributes on dependent types. This is not necessary in all cases, but is the better default. */ else if (dependent_type_p (type) - /* But attributes abi_tag and visibility specifically apply - to templates. */ + /* But some attributes specifically apply to templates. */ && !is_attribute_p ("abi_tag", name) + && !is_attribute_p ("deprecated", name) && !is_attribute_p ("visibility", name)) return true; else diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fa9652f..70f669c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7853,6 +7853,8 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, if (OVERLOAD_TYPE_P (t) && !DECL_ALIAS_TEMPLATE_P (gen_tmpl)) { + if (TREE_DEPRECATED (template_type)) + TREE_DEPRECATED (t) = true; if (tree attributes = lookup_attribute ("abi_tag", TYPE_ATTRIBUTES (template_type))) { diff --git a/gcc/testsuite/g++.dg/ext/attr-deprecated-1.C b/gcc/testsuite/g++.dg/ext/attr-deprecated-1.C new file mode 100644 index 0000000..4a3098b --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-deprecated-1.C @@ -0,0 +1,2 @@ +template struct __attribute__ ((deprecated)) S {}; +S s; // { dg-warning "deprecated" }