c++: DR 1914 - Allow duplicate standard attributes.
Following Joseph's change for C to allow duplicate C2x standard attributes
<https://gcc.gnu.org/pipermail/gcc-patches/2020-October/557272.html>,
this patch does a similar thing for C++. This is DR 1914, to be resolved by
<wg21.link/p2156>, which is not part of the standard yet, but has wide
support so looks like a shoo-in. The duplications now produce warnings
instead, but only if the attribute wasn't specified via a macro.
gcc/c-family/ChangeLog:
DR 1914
* c-common.c (attribute_fallthrough_p): Tweak the warning
message.
gcc/cp/ChangeLog:
DR 1914
* parser.c (cp_parser_check_std_attribute): Return bool. Add a
location_t parameter. Return true if the attribute wasn't duplicated.
Give a warning instead of an error. Check more attributes.
(cp_parser_std_attribute_list): Don't add duplicated attributes to
the list. Pass location to cp_parser_check_std_attribute.
gcc/testsuite/ChangeLog:
DR 1914
* c-c++-common/attr-fallthrough-2.c: Adjust dg-warning.
* g++.dg/cpp0x/fallthrough2.C: Likewise.
* g++.dg/cpp0x/gen-attrs-60.C: Turn dg-error into dg-warning.
* g++.dg/cpp1y/attr-deprecated-2.C: Likewise.
* g++.dg/cpp2a/attr-likely2.C: Adjust dg-warning.
* g++.dg/cpp2a/nodiscard-once.C: Turn dg-error into dg-warning.
* g++.dg/cpp0x/gen-attrs-72.C: New test.