mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-12 21:41:35 +08:00
Implement some changes to the currently supported C2x standard attributes that have been made to the specification since they were first implemented in GCC, and some consequent changes: * maybe_unused is now supported on labels. In fact that was already accidentally supported in GCC as a result of sharing the implementation with __attribute__ ((unused)), but needed to be covered in the tests. * As part of the support for maybe_unused on labels, its __has_c_attribute value changed. * The issue of maybe_unused accidentally being already supported on labels showed up the lack of tests for other standard attributes being incorrectly applied to labels; add such tests. * Use of fallthrough or nodiscard attributes on labels already properly resulted in a pedwarn. For the deprecated attribute, however, there was only a warning, and the wording "'deprecated' attribute ignored for 'void'" included an unhelpful "for 'void'". Arrange for the case of the deprecated attribute on a label to be checked for separately and result in a pedwarn. As with inappropriate uses of fallthrough (see commit 6c80b1b56dec2691436f3e2676e3d1b105b01b89), it seems reasonable for this pedwarn to apply regardless of whether [[]] or __attribute__ was used and regardless of whether C or C++ is being compiled. * Attributes on case or default labels (the standard syntax supports attributes on all kinds of labels) were quietly ignored, whether or not appropriate for use in such a context, because they weren't passed to decl_attributes at all. (Note where I'm changing the do_case prototype that such a function is actually only defined in the C front end, not for C++, despite the declaration being in c-common.h.) * A recent change as part of the editorial review in preparation for the C2x CD ballot has changed the __has_c_attribute value for fallthrough to 201910 to reflect when that attribute was actually voted into the working draft. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c-family/ * c-attribs.cc (handle_deprecated_attribute): Check and pedwarn for LABEL_DECL. * c-common.cc (c_add_case_label): Add argument ATTRS. Call decl_attributes. * c-common.h (do_case, c_add_case_label): Update declarations. * c-lex.cc (c_common_has_attribute): For C, produce a result of 201910 for fallthrough and 202106 for maybe_unused. gcc/c/ * c-parser.cc (c_parser_label): Pass attributes to do_case. * c-typeck.cc (do_case): Add argument ATTRS. Pass it to c_add_case_label. gcc/testsuite/ * gcc.dg/c2x-attr-deprecated-2.c, gcc.dg/c2x-attr-fallthrough-2.c, gcc.dg/c2x-attr-maybe_unused-1.c, gcc.dg/c2x-attr-nodiscard-2.c: Add tests of attributes on labels. * gcc.dg/c2x-has-c-attribute-2.c: Update expected results for maybe_unused and fallthrough.
…
…
…
…
…
…
…
…
…
…
…
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.
Description
Languages
C++
31.9%
C
31.3%
Ada
12%
D
6.5%
Go
6.4%
Other
11.5%