99769e7fb6
For: enum a { A }; enum a { B }; we emit a bogus error about nested definitions before the real error: foo.c:2:6: error: nested redefinition of ‘enum a’ 2 | enum a { B }; | ^ foo.c:2:6: error: redeclaration of ‘enum a’ foo.c:1:6: note: originally defined here 1 | enum a { A }; | ^ This is because we weren't clearing C_TYPE_BEING_DEFINED once the definition was over. I think it's OK to clear C_TYPE_BEING_DEFINED even for a definition that actually is nested (and so whose outer definition is still open), since we'll already have given an error by then. It means that second and subsequent attempts to define a nested enum will usually get the redeclaration error instead of the nested error, but that seems just as accurate (nested_first and nested_second in the test). The only exception is if the first nested enum was also invalid by being empty, but then the enum as a whole has already produced two errors (nested_empty in the test). 2019-08-08 Richard Sandiford <richard.sandiford@arm.com> gcc/c/ * c-decl.c (finish_enum): Clear C_TYPE_BEING_DEFINED. gcc/testsuite/ * gcc.dg/pr79983.c (enum E): Don't allow an error about nested definitions. * gcc.dg/enum-redef-1.c: New test. From-SVN: r274213 |
||
---|---|---|
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libhsail-rt | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
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.