public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ibm/heads/gcc-9)] c++: Fix deprecated attribute handling on templates (PR c++/93228)
@ 2020-02-04 21:15 Peter Bergner
0 siblings, 0 replies; only message in thread
From: Peter Bergner @ 2020-02-04 21:15 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:514314b73109b3672ecb3c3c04f614bb7c7fef57
commit 514314b73109b3672ecb3c3c04f614bb7c7fef57
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Jan 22 17:52:11 2020 +0100
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.
Diff:
---
gcc/cp/ChangeLog | 9 +++++++++
gcc/cp/parser.c | 12 +++++++++++-
gcc/testsuite/ChangeLog | 8 ++++++++
gcc/testsuite/g++.dg/cpp1y/attr-deprecated-3.C | 13 +++++++++++++
4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 13601ce..da55c7a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,6 +1,15 @@
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 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-22 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
2019-12-26 Jakub Jelinek <jakub@redhat.com>
PR c++/92438
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 54b3522..3e9950b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16732,7 +16732,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
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c313090..d49da0a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,14 @@
2020-01-22 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2020-01-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/93228
+ * g++.dg/cpp1y/attr-deprecated-3.C: New test.
+
+2020-01-22 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
2020-01-15 Jakub Jelinek <jakub@redhat.com>
PR target/93009
diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-3.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-3.C
new file mode 100644
index 0000000..16e5018
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-3.C
@@ -0,0 +1,13 @@
+// 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" }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-04 21:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 21:15 [gcc(refs/vendors/ibm/heads/gcc-9)] c++: Fix deprecated attribute handling on templates (PR c++/93228) Peter Bergner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).