Joseph Myers 2eca4ff4e8 c: C2x attributes fixes and updates
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.
2022-08-31 22:24:32 +00:00
2022-03-19 00:16:22 +00:00
2022-08-31 22:24:32 +00:00
2022-08-31 00:16:45 +00:00
2022-07-13 00:16:33 +00:00
2021-11-30 00:16:44 +00:00
2022-08-26 00:16:21 +00:00
2022-08-31 00:16:45 +00:00
2022-07-09 00:16:54 +00:00
2022-06-28 00:16:58 +00:00
2022-06-04 00:16:27 +00:00
2022-05-21 00:16:32 +00:00
2021-11-16 00:16:31 +00:00
2022-08-27 00:17:09 +00:00
2022-07-30 10:35:23 -07:00
2022-08-27 00:17:09 +00:00
2022-08-26 00:16:21 +00:00
2022-08-26 00:16:21 +00:00
2022-08-26 00:16:21 +00:00
2022-08-28 00:16:28 +00:00
2022-08-26 00:16:21 +00:00
2022-08-26 00:16:21 +00:00
2022-08-26 00:16:21 +00:00
2022-08-02 00:16:51 +00:00
2022-07-29 00:16:21 +00:00
2022-08-26 00:16:21 +00:00
2022-07-19 17:07:04 +03:00
2022-08-19 00:16:27 +00:00
2021-12-21 09:10:57 +01:00
2022-08-04 13:38:28 -07:00

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
No description provided
Readme 2.1 GiB
Languages
C++ 31.9%
C 31.3%
Ada 12%
D 6.5%
Go 6.4%
Other 11.5%