Go to file
Joseph Myers 2cc94aa8d8 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.

From-SVN: r278268
2019-11-15 00:06:30 +00:00
config
contrib download_prerequisites: Use http instead of ftp for downloading. 2019-11-13 19:48:52 +02:00
fixincludes
gcc Support C2x [[deprecated]] attribute. 2019-11-15 00:06:30 +00:00
gnattools
gotools
include GCN libgomp port 2019-11-13 12:38:04 +00:00
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcpp Support UTF-8 character constants for C2x. 2019-11-14 20:18:33 +00:00
libdecnumber
libffi
libgcc Update the arm-*-vxworks* support 2019-11-14 16:11:30 +00:00
libgfortran PR fortran/92470 Fixes for CFI_address 2019-11-13 12:13:57 +01:00
libgo libgo: fix DejaGNU testsuite compiler when using build sysroot 2019-11-11 23:28:54 +00:00
libgomp GCN Libgomp Plugin 2019-11-13 12:38:18 +00:00
libhsail-rt
libiberty PR c++/91979 - mangling nullptr expression 2019-11-04 18:24:25 -05:00
libitm
libobjc
liboffloadmic
libphobos
libquadmath
libsanitizer Enable libsanitizer build on riscv64 2019-11-13 09:45:15 +00:00
libssp
libstdc++-v3 libstdc++: Implement new predicate concepts from P1716R3 2019-11-14 16:53:18 +00:00
libvtv
lto-plugin
maintainer-scripts update_version_svn (IGNORE_BRANCHES): Add 7. 2019-11-14 07:41:56 +00:00
zlib
.dir-locals.el
.gitattributes * .gitattributes: Also check ChangeLog whitespace. 2019-10-21 23:12:04 -04:00
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Bump minimum MPFR version to 3.1.0 2019-11-11 17:59:48 +02:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure Bump minimum MPFR version to 3.1.0 2019-11-11 17:59:48 +02:00
configure.ac Bump minimum MPFR version to 3.1.0 2019-11-11 17:59:48 +02:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Remove Cell Broadband Engine SPU targets 2019-10-08 12:20:50 +02:00
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

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.