From c60a18f8056facdcf370ce0e5f51550c9df5b539 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 17 Jan 2020 15:22:22 +0100 Subject: c++: Fix deprecated attribute handling on templates (PR c++/93228) As the following testcase shows, when deprecated attribute is on a template, we'd never print the message if any, because the attribute is not present on the TEMPLATE_DECL with which warn_deprecated_use is called, but on its DECL_TEMPLATE_RESULT or its type. 2020-01-17 Jakub Jelinek PR c++/93228 * parser.c (cp_parser_template_name): Look up deprecated attribute in DECL_TEMPLATE_RESULT or its type's attributes. * g++.dg/cpp1y/attr-deprecated-3.C: New test. --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c37e461..d76675e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-17 Jakub Jelinek + + PR c++/93228 + * parser.c (cp_parser_template_name): Look up deprecated attribute + in DECL_TEMPLATE_RESULT or its type's attributes. + 2020-01-16 Jason Merrill PR c++/93286 - ICE with __is_constructible and variadic template. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c5f9798..728474d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -16884,7 +16884,17 @@ cp_parser_template_name (cp_parser* parser, { if (TREE_DEPRECATED (decl) && deprecated_state != DEPRECATED_SUPPRESS) - warn_deprecated_use (decl, NULL_TREE); + { + tree d = DECL_TEMPLATE_RESULT (decl); + tree attr; + if (TREE_CODE (d) == TYPE_DECL) + attr = lookup_attribute ("deprecated", + TYPE_ATTRIBUTES (TREE_TYPE (d))); + else + attr = lookup_attribute ("deprecated", + DECL_ATTRIBUTES (d)); + warn_deprecated_use (decl, attr); + } } else { -- cgit v1.1