Go to file
Richard Sandiford 99769e7fb6 [C] Fix bogus nested enum error message
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
2019-08-08 17:12:05 +00:00
config Add a build config for bootstrapping at -Og 2019-07-08 06:21:11 +00:00
contrib
fixincludes
gcc [C] Fix bogus nested enum error message 2019-08-08 17:12:05 +00:00
gnattools
gotools
include Fix file descriptor existence of MinGW. 2019-08-08 07:50:28 +00:00
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcpp PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs 2019-07-09 12:32:49 -06:00
libdecnumber
libffi
libgcc config.gcc (hppa*-*-netbsd*): New target. 2019-07-31 14:11:16 +00:00
libgfortran PR 53796 Make inquire(file=, recl=) conform to F2018 2019-08-07 10:34:10 +03:00
libgo runtime: expose the g variable 2019-07-15 21:17:16 +00:00
libgomp gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT for VLA helper variables on target data even if... 2019-08-08 08:39:02 +02:00
libhsail-rt
libiberty Fix file descriptor existence of MinGW. 2019-08-08 07:50:28 +00:00
libitm
libobjc
liboffloadmic
libphobos
libquadmath quadmath.h (M_Eq, [...]): Use two more decimal places. 2019-08-02 09:59:19 +02:00
libsanitizer
libssp
libstdc++-v3 P0325R4 to_array from LFTS with updates 2019-08-08 11:18:53 +01:00
libvtv
lto-plugin
maintainer-scripts update_web_docs_svn: Proceed even if the invocation of sphinx fails. 2019-08-04 22:31:54 +00:00
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog MAINTAINERS (Write After Approval): Remove myself, already listed in RISC-V port maitainer. 2019-07-08 13:21:21 +00:00
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 MAINTAINERS (Write After Approval): Remove myself, already listed in RISC-V port maitainer. 2019-07-08 13:21:21 +00: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.