Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 202231) +++ cp/typeck2.c (working copy) @@ -1761,7 +1761,14 @@ build_functional_cast (tree exp, tree parms, tsubs return error_mark_node; if (TREE_CODE (exp) == TYPE_DECL) - type = TREE_TYPE (exp); + { + type = TREE_TYPE (exp); + + if (complain & tf_warning + && TREE_DEPRECATED (type) + && DECL_ARTIFICIAL (exp)) + warn_deprecated_use (type, NULL_TREE); + } else type = exp; Index: testsuite/g++.dg/warn/deprecated-8.C =================================================================== --- testsuite/g++.dg/warn/deprecated-8.C (revision 0) +++ testsuite/g++.dg/warn/deprecated-8.C (working copy) @@ -0,0 +1,15 @@ +// PR c++/58305 + +class ToBeDeprecated { +} __attribute__ ((deprecated ("deprecated!"))); + +typedef ToBeDeprecated NotToBeDeprecated; // { dg-warning "'ToBeDeprecated' is deprecated" } + +int main() { + + ToBeDeprecated(); // { dg-warning "'ToBeDeprecated' is deprecated" } + ToBeDeprecated x; // { dg-warning "'ToBeDeprecated' is deprecated" } + + NotToBeDeprecated(); + NotToBeDeprecated y; +}