Commit c60a18f8 by Jakub Jelinek

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  <jakub@redhat.com>

	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.
parent bf09d886
2020-01-17 Jakub Jelinek <jakub@redhat.com>
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 <jason@redhat.com> 2020-01-16 Jason Merrill <jason@redhat.com>
PR c++/93286 - ICE with __is_constructible and variadic template. PR c++/93286 - ICE with __is_constructible and variadic template.
......
...@@ -16884,7 +16884,17 @@ cp_parser_template_name (cp_parser* parser, ...@@ -16884,7 +16884,17 @@ cp_parser_template_name (cp_parser* parser,
{ {
if (TREE_DEPRECATED (decl) if (TREE_DEPRECATED (decl)
&& deprecated_state != DEPRECATED_SUPPRESS) && 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 else
{ {
2020-01-17 Jakub Jelinek <jakub@redhat.com>
PR c++/93228
* g++.dg/cpp1y/attr-deprecated-3.C: New test.
2020-01-17 Richard Sandiford <richard.sandiford@arm.com> 2020-01-17 Richard Sandiford <richard.sandiford@arm.com>
* g++.target/aarch64/sve/acle/general-c++/gimplify_1.C: New test. * g++.target/aarch64/sve/acle/general-c++/gimplify_1.C: New test.
......
// PR c++/93228
// { dg-do compile { target c++14 } }
template <typename T>
struct [[deprecated("foo")]] bar {}; // { dg-message "declared here" }
struct [[deprecated("baz")]] qux {}; // { dg-message "declared here" }
void
quux ()
{
bar<int> b; // { dg-warning "is deprecated: foo" }
qux c; // { dg-warning "is deprecated: baz" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment