diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 2 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 12 |
3 files changed, 17 insertions, 3 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index fdc9153..c2cab57 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,11 @@ 2019-11-15 Joseph Myers <joseph@codesourcery.com> + * c-decl.c (std_attribute_table): Add fallthrough. + * c-parser.c (c_parser_declaration_or_fndef): Diagnose fallthrough + attribute at top level. + +2019-11-15 Joseph Myers <joseph@codesourcery.com> + * c-decl.c (std_attribute_table): New. (c_init_decl_processing): Register attributes from std_attribute_table. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index a7f7c69..98b71ea 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -4343,6 +4343,8 @@ const struct attribute_spec std_attribute_table[] = affects_type_identity, handler, exclude } */ { "deprecated", 0, 1, false, false, false, false, handle_deprecated_attribute, NULL }, + { "fallthrough", 0, 0, false, false, false, false, + handle_fallthrough_attribute, NULL }, { NULL, 0, 0, false, false, false, false, NULL, NULL } }; diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 721158a..5b290bf 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1927,9 +1927,15 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, { if (fallthru_attr_p != NULL) *fallthru_attr_p = true; - tree fn = build_call_expr_internal_loc (here, IFN_FALLTHROUGH, - void_type_node, 0); - add_stmt (fn); + if (nested) + { + tree fn = build_call_expr_internal_loc (here, IFN_FALLTHROUGH, + void_type_node, 0); + add_stmt (fn); + } + else + pedwarn (here, OPT_Wattributes, + "%<fallthrough%> attribute at top level"); } else if (empty_ok && !(have_attrs && specs->non_std_attrs_seen_p)) |