This is the mail archive of the gcc-cvs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

r278268 - in /trunk/gcc: c-family/ChangeLog c-f...


Author: jsm28
Date: Fri Nov 15 00:06:30 2019
New Revision: 278268

URL: https://gcc.gnu.org/viewcvs?rev=278268&root=gcc&view=rev
Log:
Support C2x [[deprecated]] attribute.

This patch adds support for the C2x [[deprecated]] attribute.  All the
actual logic for generating warnings can be identical to the GNU
__attribute__ ((deprecated)), as can the attribute handler, so this is
just a matter of wiring things up appropriately and adding the checks
specified in the standard.  Unlike for C++, this patch gives
"deprecated" an entry in a table of standard attributes rather than
remapping it internally to the GNU attribute, as that seems a cleaner
approach to me.

Specifically, the only form of arguments to the attribute permitted in
the standard is (string-literal); empty parentheses are not permitted
in the case of no arguments, and a string literal (which includes
concatenated adjacent string literals, because concatenation is an
earlier phase of translation) cannot have further redundant
parentheses around it.  For the case of empty parentheses, this patch
makes the C parser disallow them for all known attributes using the
[[]] syntax, as done for C++.  For string literals (where the C++
front end is missing the check to avoid redundant parentheses, 92521
filed for that issue), a special case is inserted in the C parser.

A known issue that I think can be addressed later as a bug fix is that
the warnings for the attribute being ignored in certain cases
(attribute declarations, statements, most uses on types) ought to be
pedwarns, as those usages are constraint violations.

Bad handling of wide string literals with this attribute is also a
pre-existing bug (91182 - although that's filed as a C++ bug, the code
in question is language-independent, in tree.c).

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/c:
	* c-decl.c (std_attribute_table): New.
	(c_init_decl_processing): Register attributes from
	std_attribute_table.
	* c-parser.c (c_parser_attribute_arguments): Add arguments
	require_string and allow_empty_args.  All callers changed.
	(c_parser_std_attribute): Set require_string argument for
	"deprecated" attribute.

gcc/c-family:
	* c-attribs.c (handle_deprecated_attribute): Remove static.
	* c-common.h (handle_deprecated_attribute): Declare.

gcc/testsuite:
	* gcc.dg/c2x-attr-deprecated-1.c, gcc.dg/c2x-attr-deprecated-2.c,
	gcc.dg/c2x-attr-deprecated-3.c: New tests.

Added:
    trunk/gcc/testsuite/gcc.dg/c2x-attr-deprecated-1.c
    trunk/gcc/testsuite/gcc.dg/c2x-attr-deprecated-2.c
    trunk/gcc/testsuite/gcc.dg/c2x-attr-deprecated-3.c
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-attribs.c
    trunk/gcc/c-family/c-common.h
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/c/c-parser.c
    trunk/gcc/testsuite/ChangeLog


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]