Go to file
Joseph Myers 8f51cf38bb preprocessor: Fix pp-number lexing of digit separators [PR83873, PR97604]
When the preprocessor lexes preprocessing numbers in lex_number, it
accepts digit separators in more cases than actually permitted in
pp-numbers by the standard syntax.

One thing this accepts is adjacent digit separators; there is some
code to reject those later, but as noted in bug 83873 it fails to
cover the case of adjacent digit separators within a floating-point
exponent.  Accepting adjacent digit separators only results in a
missing diagnostic, not in valid code being rejected or being accepted
with incorrect semantics, because the correct lexing in such a case
would have '' start the following preprocessing tokens, and no valid
preprocessing token starts '' while ' isn't valid on its own as a
preprocessing token either.  So this patch fixes that case by moving
the error for adjacent digit separators to lex_number (allowing a more
specific diagnostic than if '' were excluded from the pp-number
completely).

Other cases inappropriately accepted involve digit separators before
'.', 'e+', 'e-', 'p+' or 'p-' (or corresponding uppercase variants).
In those cases, as shown by the test digit-sep-pp-number.C added, this
can result in valid code being wrongly rejected as a result of too
many characters being included in the pp-number.  So this case is
fixed by terminating the pp-number at the correct character according
to the standard.  That test also covers the case where a digit
separator was followed by an identifier-nondigit that is not a
nondigit (e.g. a UCN); that case was already handled correctly.

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

libcpp/
	PR c++/83873
	PR preprocessor/97604
	* lex.c (lex_number): Reject adjacent digit separators here.  Do
	not allow digit separators before '.' or an exponent with sign.
	* expr.c (cpp_classify_number): Do not check for adjacent digit
	separators here.

gcc/testsuite/
	PR c++/83873
	PR preprocessor/97604
	* g++.dg/cpp1y/digit-sep-neg-2.C,
	g++.dg/cpp1y/digit-sep-pp-number.C: New tests.
	* g++.dg/cpp1y/digit-sep-line-neg.C, g++.dg/cpp1y/digit-sep-neg.C:
	Adjust expected messages.
2021-05-06 23:20:35 +00:00
INSTALL
c++tools Daily bump. 2021-04-02 00:16:26 +00:00
config Daily bump. 2021-05-04 00:16:53 +00:00
contrib Daily bump. 2021-04-28 00:16:36 +00:00
fixincludes
gcc preprocessor: Fix pp-number lexing of digit separators [PR83873, PR97604] 2021-05-06 23:20:35 +00:00
gnattools
gotools
include libiberty: add htab_eq_string 2021-05-06 08:51:28 -06:00
intl Daily bump. 2021-04-17 00:16:25 +00:00
libada
libatomic
libbacktrace Daily bump. 2021-05-04 00:16:53 +00:00
libcc1 Daily bump. 2021-05-06 00:16:37 +00:00
libcody Daily bump. 2021-04-07 00:16:39 +00:00
libcpp preprocessor: Fix pp-number lexing of digit separators [PR83873, PR97604] 2021-05-06 23:20:35 +00:00
libdecnumber Daily bump. 2021-05-04 00:16:53 +00:00
libffi
libgcc Daily bump. 2021-04-30 00:16:37 +00:00
libgfortran Daily bump. 2021-05-06 00:16:37 +00:00
libgo libgo: update to Go1.16.3 release 2021-04-12 15:23:16 -07:00
libgomp Daily bump. 2021-05-05 00:16:54 +00:00
libhsail-rt
libiberty libiberty: add htab_eq_string 2021-05-06 08:51:28 -06:00
libitm
libobjc
liboffloadmic
libphobos Daily bump. 2021-04-22 00:16:32 +00:00
libquadmath
libsanitizer Daily bump. 2021-04-18 00:16:21 +00:00
libssp
libstdc++-v3 libstdc++: Improve static assert messages 2021-05-06 16:07:10 +01:00
libvtv
lto-plugin Daily bump. 2021-05-04 00:16:53 +00:00
maintainer-scripts Daily bump. 2021-04-21 00:16:23 +00:00
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2021-05-05 00:16:54 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Add myself for write after approval 2021-04-23 09:12:43 -07:00
Makefile.def sim: drop dep on configure-gdb 2021-03-12 19:48:13 -05:00
Makefile.in sim: drop dep on configure-gdb 2021-03-12 19:48:13 -05:00
Makefile.tpl Add -fprofile-reproducible=parallel-runs to STAGEfeedback_CFLAGS to Makefile.tpl. 2021-03-11 16:18:56 +01:00
README
ar-lib
compile
config-ml.in
config.guess config.sub, config.guess : Import upstream 2021-01-25. 2021-02-23 17:21:10 +08:00
config.rpath
config.sub config.sub, config.guess : Import upstream 2021-01-25. 2021-02-23 17:21:10 +08:00
configure Replace AC_PROG_CC with AC_PROG_CC_C99 in top level configure file. 2021-05-04 13:39:04 +01:00
configure.ac Replace AC_PROG_CC with AC_PROG_CC_C99 in top level configure file. 2021-05-04 13:39:04 +01:00
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

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.