diff options
author | Joseph Myers <joseph@codesourcery.com> | 2019-11-15 01:33:37 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2019-11-15 01:33:37 +0000 |
commit | f8aea5e37d12e09fef68b854a190f71d6b39e11f (patch) | |
tree | af29d11914c8522b85aaac821765cf424cea24f3 /gcc/c-family/c-attribs.c | |
parent | d3cb8f004a3c1ea3de3d948d80f5faabadd1f0b0 (diff) | |
download | gcc-f8aea5e37d12e09fef68b854a190f71d6b39e11f.zip gcc-f8aea5e37d12e09fef68b854a190f71d6b39e11f.tar.gz gcc-f8aea5e37d12e09fef68b854a190f71d6b39e11f.tar.bz2 |
Improve checks on C2x fallthrough attribute.
When adding C2x attribute support, some [[fallthrough]] support
appeared as a side-effect because of code for that attribute going
through separate paths from the normal attribute handling.
However, going through those paths without the normal attribute
handlers meant that certain checks, such as for the invalid usage
[[fallthrough()]], did not operate. This patch improves checks by
adding this attribute to the standard attribute table, so that the
parser knows it expects no arguments, along with adding an explicit
check for "[[fallthrough]];" attribute-declarations at top level. As
with other attributes, there are still cases where warnings should be
pedwarns because C2x constraints are violated, but this patch improves
the attribute handling.
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
gcc/c:
* c-decl.c (std_attribute_table): Add fallthrough.
* c-parser.c (c_parser_declaration_or_fndef): Diagnose fallthrough
attribute at top level.
gcc/c-family:
* c-attribs.c (handle_fallthrough_attribute): Remove static.
* c-common.h (handle_fallthrough_attribute): Declare.
gcc/testsuite:
* gcc.dg/c2x-attr-fallthrough-2.c,
gcc.dg/c2x-attr-fallthrough-3.c: New tests.
From-SVN: r278273
Diffstat (limited to 'gcc/c-family/c-attribs.c')
-rw-r--r-- | gcc/c-family/c-attribs.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 18b829f..4a59cdf 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -144,7 +144,6 @@ static tree handle_simd_attribute (tree *, tree, tree, int, bool *); static tree handle_omp_declare_target_attribute (tree *, tree, tree, int, bool *); static tree handle_designated_init_attribute (tree *, tree, tree, int, bool *); -static tree handle_fallthrough_attribute (tree *, tree, tree, int, bool *); static tree handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *); static tree handle_copy_attribute (tree *, tree, tree, int, bool *); @@ -4114,7 +4113,7 @@ handle_designated_init_attribute (tree *node, tree name, tree, int, /* Handle a "fallthrough" attribute; arguments as in struct attribute_spec.handler. */ -static tree +tree handle_fallthrough_attribute (tree *, tree name, tree, int, bool *no_add_attrs) { |