aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/expressionsem.d
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/d/dmd/expressionsem.d
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/d/dmd/expressionsem.d')
0 files changed, 0 insertions, 0 deletions