c++: DR 1914 - Allow duplicate standard attributes.
authorMarek Polacek <polacek@redhat.com>
Fri, 6 Nov 2020 17:33:53 +0000 (12:33 -0500)
committerMarek Polacek <polacek@redhat.com>
Mon, 9 Nov 2020 23:22:58 +0000 (18:22 -0500)
commit04126e46eb2d829d7b4149d394b667e878912cc8
treed335d40d1f5e99dad16532ef1f34e6099465ff31
parentd3fd75d869480044213553000d2c9dc236a4f7af
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.
gcc/c-family/c-common.c
gcc/cp/parser.c
gcc/testsuite/c-c++-common/attr-fallthrough-2.c
gcc/testsuite/g++.dg/cpp0x/fallthrough2.C
gcc/testsuite/g++.dg/cpp0x/gen-attrs-60.C
gcc/testsuite/g++.dg/cpp0x/gen-attrs-72.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/attr-deprecated-2.C
gcc/testsuite/g++.dg/cpp2a/attr-likely2.C
gcc/testsuite/g++.dg/cpp2a/nodiscard-once.C