]> gcc.gnu.org Git - gcc.git/commit
c++: Minimal handling of carries_dependency attribute
authorJakub Jelinek <jakub@redhat.com>
Wed, 9 Nov 2022 10:39:22 +0000 (11:39 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 9 Nov 2022 10:39:22 +0000 (11:39 +0100)
commit05119c345797bc04cc34e6973ebd921b4dcb0326
tree3c6d80d9a90689dcffa303891ba18ac757e48306
parentcecc039fbb4ffdb0e5185fdd7f8f87c3eec68832
c++: Minimal handling of carries_dependency attribute

A comment in D2552R1:
"The only questionable (but still conforming) case we found was
[[carries_dependency(some_argument)]] on GCC, where the emitted diagnostic said that the
carries_dependency attribute is not supported, but did not specifically call out the syntax error
in the argument clause."
made me try the following patch, where we'll error at least
for arguments to the attribute and for some uses of the attribute
appertaining to something not mentioned in the standard warn
with different diagnostics (or should that be an error?; clang++
does that, but I think we never do for any attribute, standard or not).
The diagnostics on toplevel attribute declaration is still an
attribute ignored warning and on empty statement different wording.

The paper additionally mentions
struct X { [[nodiscard]]; }; // no diagnostic on GCC
and 2 cases of missing diagnostics on [[fallthrough]] (guess I should
file a PR about those; one problem is that do { ... } while (0); there
is replaced during genericization just by ... and another that
[[fallthrough]] there is followed by a label, but not user/case/default
label, but an artificial one created from while loop genericization.

2022-11-09  Jakub Jelinek  <jakub@redhat.com>

* tree.cc (handle_carries_dependency_attribute): New function.
(std_attribute_table): Add carries_dependency attribute.
* parser.cc (cp_parser_check_std_attribute): Add carries_dependency
attribute.

* g++.dg/cpp0x/attr-carries_dependency1.C: New test.
gcc/cp/parser.cc
gcc/cp/tree.cc
gcc/testsuite/g++.dg/cpp0x/attr-carries_dependency1.C [new file with mode: 0644]
This page took 0.063285 seconds and 5 git commands to generate.