aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cp-tree.h
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2022-02-25 14:56:13 -0500
committerMarek Polacek <polacek@redhat.com>2022-02-28 11:37:49 -0500
commit430c89274d7f82810724126637ffdc5507d442f0 (patch)
treebc4c5c862fc47548e3a9e77f62f9e5739965005e /gcc/cp/cp-tree.h
parentc8b0571e334792c0c789438617cfb7faf86ab599 (diff)
downloadgcc-430c89274d7f82810724126637ffdc5507d442f0.zip
gcc-430c89274d7f82810724126637ffdc5507d442f0.tar.gz
gcc-430c89274d7f82810724126637ffdc5507d442f0.tar.bz2
c++: Lost deprecated/unavailable attr in class tmpl [PR104682]
When looking into the other PR I noticed that we fail to give a warning for a deprecated enumerator when the enum is in a class template. This only happens when the attribute doesn't have an argument. The reason is that when we tsubst_enum, we create a new enumerator: build_enumerator (DECL_NAME (decl), value, newtag, DECL_ATTRIBUTES (decl), DECL_SOURCE_LOCATION (decl)); but DECL_ATTRIBUTES (decl) is null when the attribute was provided without an argument -- in that case it simply melts into a tree flag. handle_deprecated_attribute has: if (!args) *no_add_attrs = true; so the attribute isn't retained and we lose it when tsubsting. Same thing when the attribute is on the enum itself. Attribute unavailable is a similar case, but it's different in that it can be a late attribute whereas "deprecated" can't: is_late_template_attribute has /* 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 return false; which looks strange, but attr-unavailable-9.C tests that we don't error when the attribute is applied on a template. PR c++/104682 gcc/cp/ChangeLog: * cp-tree.h (build_enumerator): Adjust. * decl.cc (finish_enum): Make it return the new decl. * pt.cc (tsubst_enum): Propagate TREE_DEPRECATED and TREE_UNAVAILABLE. gcc/testsuite/ChangeLog: * g++.dg/ext/attr-unavailable-10.C: New test. * g++.dg/ext/attr-unavailable-11.C: New test. * g++.dg/warn/deprecated-17.C: New test. * g++.dg/warn/deprecated-18.C: New test.
Diffstat (limited to 'gcc/cp/cp-tree.h')
-rw-r--r--gcc/cp/cp-tree.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 37d462f..80994e9 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6833,7 +6833,7 @@ extern void xref_basetypes (tree, tree);
extern tree start_enum (tree, tree, tree, tree, bool, bool *);
extern void finish_enum_value_list (tree);
extern void finish_enum (tree);
-extern void build_enumerator (tree, tree, tree, tree, location_t);
+extern tree build_enumerator (tree, tree, tree, tree, location_t);
extern tree lookup_enumerator (tree, tree);
extern bool start_preparsed_function (tree, tree, int);
extern bool start_function (cp_decl_specifier_seq *,