Go to file
Joseph Myers 1723e1bedb Properly handle C2x attributes on types.
attribs.c has code to ignore all scoped attributes appertaining to
types except when they are part of the definition of that type.

I think the premise of that code is incorrect, and its presence is a
bug; such attributes are clearly valid in both C and C++, which
explicitly specify that attributes in certain syntactic positions
appertain to a particular type, only for that use of that type and not
for other uses of the same type specifiers without that attribute
specified, and while the standard attributes in C2x aren't relevant in
such contexts, some gnu:: attributes certainly are.  Where some
attributes are invalid on some types in such contexts, that's a matter
for the individual attribute handlers to diagnose (or the front end if
the requirements on a standard attribute in the standard are more
strict than those of a handler shared with a GNU attribute).

Thus, this patch removes the bogus code to allow such attributes to be
used.  Doing so (and adding tests for attributes in such positions)
shows up that the logic in the C front end for creating the
c_declarator structures for such attributes put them in the wrong
place relative to the structures for function and array types, and the
logic for postfix attributes on a list of declaration specifiers
failed to handle some cases, so those bugs are also fixed in this
patch.

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

gcc:
	* attribs.c (decl_attributes): Do not ignore C++11 attributes on
	types.

gcc/c:
	* c-tree.h (struct c_declarator): Use a structure for id member.
	* c-decl.c (grokdeclarator): Extract attributes from cdk_id
	declarators at the start, not when handling individual declarators
	later.  Use u.id.id instead of u.id.
	(grokfield): Use u.id.id instead of u.id.
	(build_id_declarator): Set u.id.id and u.id.attrs.
	(finish_declspecs): Handle postfix attributes in case of typedef
	name or typeof used.
	* c-parser.c (c_parser_direct_declarator)
	(c_parser_direct_declarator_inner): Place declarator for
	attributes inside that for function or array, not outside.  Set
	u.id.attrs for identifiers.
	(c_parser_parameter_declaration): Use u.id.id instead of u.id.
	* gimple-parser.c (c_parser_gimple_declaration): Use u.id.id
	instead of u.id.

gcc/testsuite:
	* gcc.dg/gnu2x-attrs-1.c: Do not expect message about attributes
	appertaining to types.
	* gcc.dg/gnu2x-attrs-2.c: New test.
	* g++.dg/cpp0x/gen-attrs-1.C, g++.dg/cpp0x/gen-attrs-22.C,
	g++.dg/cpp0x/gen-attrs-4.C, g++.dg/cpp0x/lambda/lambda-attr1.C:
	Update expected diagnostics.

From-SVN: r278683
2019-11-25 13:42:49 +00:00
config
contrib
fixincludes
gcc Properly handle C2x attributes on types. 2019-11-25 13:42:49 +00:00
gnattools
gotools
include
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcpp
libdecnumber
libffi
libgcc
libgfortran re PR libfortran/92100 (Formatted stream IO irreproducible read with binary data in file) 2019-11-24 22:14:59 +00:00
libgo re PR go/92605 (r278509 causes/reveals issue in building go library) 2019-11-21 01:06:47 +00:00
libgomp Fix failures on Solaris with -fno-common default 2019-11-21 16:14:21 +00:00
libhsail-rt
libiberty
libitm
libobjc
liboffloadmic
libphobos
libquadmath
libsanitizer
libssp
libstdc++-v3 libstdc++: Improve _GLIBCXX_DEBUG __valid_range check 2019-11-24 17:09:44 +00:00
libvtv
lto-plugin
maintainer-scripts Switch gcc ftp URL's to https 2019-11-20 22:24:48 +02:00
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Switch gcc ftp URL's to https 2019-11-20 22:24:48 +02:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure Switch gcc ftp URL's to https 2019-11-20 22:24:48 +02:00
configure.ac Switch gcc ftp URL's to https 2019-11-20 22:24: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
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.