gcc/libcpp
Lewis Hyatt ce52f1f707 libcpp: Fix unsigned promotion for unevaluated divide by zero [PR112701]
When libcpp encounters a divide by zero while processing a constant
expression "x/y", it returns "x" as a fallback. The value of the fallback is
not normally important, since an error will be generated anyway, but if the
expression appears in an unevaluated context, such as "0 ? 0/0u : -1", then
there will be no error, and the fallback value will be meaningful to the
extent that it may cause promotion from signed to unsigned of an operand
encountered later. As the PR notes, libcpp does not do the unsigned
promotion correctly in this case; fix it by making the fallback return value
unsigned as necessary.

libcpp/ChangeLog:

	PR preprocessor/112701
	* expr.cc (num_div_op): Set unsignedp appropriately when returning a
	stub value for divide by 0.

gcc/testsuite/ChangeLog:

	PR preprocessor/112701
	* gcc.dg/cpp/expr.c: Add additional tests to cover divide by 0 in an
	unevaluated context, where the unsignedness still matters.
2023-11-27 21:19:31 -05:00
..
include c-family: Implement __has_feature and __has_extension [PR60512] 2023-11-27 10:42:55 +00:00
po Daily bump. 2023-05-10 00:17:49 +00:00
ChangeLog Daily bump. 2023-11-28 00:17:28 +00:00
ChangeLog.jit
Makefile.in libcpp: split decls out to rich-location.h 2023-11-19 06:26:40 -05:00
aclocal.m4 *: add modern gettext 2023-11-14 00:47:11 +01:00
charset.cc c++: Implement C++26 P1854R4 - Making non-encodable string literals ill-formed [PR110341] 2023-11-14 18:28:34 +01:00
combining-chars.inc diagnostics: add support for "text art" diagrams 2023-06-21 21:49:00 -04:00
config.in libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
configure libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
configure.ac libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
directives.cc c: Refer more consistently to C23 not C2X 2023-11-07 14:20:30 +00:00
errors.cc Update copyright years. 2023-01-16 11:52:17 +01:00
expr.cc libcpp: Fix unsigned promotion for unevaluated divide by zero [PR112701] 2023-11-27 21:19:31 -05:00
files.cc libcpp: Fix ICE on #include after a line marker directive [PR61474] 2023-09-20 16:44:24 -04:00
generated_cpp_wcwidth.h libcpp, contrib: Update to Unicode 15.1 2023-11-14 18:32:37 +01:00
identifiers.cc libcpp: Improve the diagnostic for poisoned identifiers [PR36887] 2023-10-23 18:35:26 -04:00
init.cc c-family: Implement __has_feature and __has_extension [PR60512] 2023-11-27 10:42:55 +00:00
internal.h libcpp: split decls out to rich-location.h 2023-11-19 06:26:40 -05:00
lex.cc libcpp: configure: drop unused Valgrind detection 2023-11-24 16:13:56 +03:00
line-map.cc diagnostics: cleanups to diagnostic-show-locus.cc 2023-11-09 17:22:52 -05:00
location-example.txt PR preprocessor/83173: Enhance -fdump-internal-locations output 2018-11-27 16:04:31 +00:00
macro.cc c-family: Implement __has_feature and __has_extension [PR60512] 2023-11-27 10:42:55 +00:00
makeucnid.cc libcpp, contrib: Update to Unicode 15.1 2023-11-14 18:32:37 +01:00
makeuname2c.cc libcpp, contrib: Update to Unicode 15.1 2023-11-14 18:32:37 +01:00
mkdeps.cc p1689r5: initial support 2023-09-19 17:32:23 -04:00
pch.cc libcpp: Improve location for macro names [PR66290] 2023-06-20 16:58:12 -04:00
printable-chars.inc diagnostics: add support for "text art" diagrams 2023-06-21 21:49:00 -04:00
symtab.cc Update copyright years. 2023-01-16 11:52:17 +01:00
system.h Update copyright years. 2023-01-16 11:52:17 +01:00
traditional.cc Update copyright years. 2023-01-16 11:52:17 +01:00
ucnid.h libcpp, contrib: Update to Unicode 15.1 2023-11-14 18:32:37 +01:00
ucnid.tab Update copyright years. 2023-01-16 11:52:17 +01:00
uname2c.h libcpp, contrib: Update to Unicode 15.1 2023-11-14 18:32:37 +01:00