05d57d6561
In r264887 I broke the build of 502.gcc_r due to an ICE. The ICE occurs when generating a location for an sprintf warning within a string literal, where the sprintf call is in a macro. The root cause is a bug in the original commit of substring locations (r239175). get_substring_ranges_for_loc has code to handle the case where the string literal is in a very long source line that exceeds the length that the current linemap can represent: the start of the token is in one line map, but then another line map is started, and the end of the token is in the new linemap. get_substring_ranges_for_loc handles this by using the linemap of the end-point when building location_t values within the string. When extracting the linemap for the endpoint in r239175 I erroneously used LRK_MACRO_EXPANSION_POINT, which should have instead been LRK_SPELLING_LOCATION. I believe this bug was dormant due to rejecting macro locations earlier in the function, but in r264887 I allowed some macro locations in order to deal with locations coming from the C++ lexer, and this uncovered the bug: if a string literal was defined in a macro, locations within the string literal would be looked up using the linemap of the expansion point of the macro, rather than of the spelling point. This would lead to garbage location_t values, and, depending on the precise line numbers of the two locations, an assertion failure (which was causing the build failure in 502.gcc_r). This patch fixes the bug by using LRK_SPELLING_LOCATION, and adds some bulletproofing to the "two linemaps" case. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu (g++.sum gained 5 PASS results; gcc.sum gained 3 PASS results). I also verified that this fixes the build of 502.gcc_r. gcc/ChangeLog: PR tree-optimization/87562 * input.c (get_substring_ranges_for_loc): Use LRK_SPELLING_LOCATION rather than LRK_MACRO_EXPANSION_POINT when getting the linemap for the endpoint. Verify that it's either in the same linemap as the start point's spelling location, or at least in the same file. gcc/testsuite/ChangeLog: PR tree-optimization/87562 * c-c++-common/substring-location-PR-87562-1-a.h: New file. * c-c++-common/substring-location-PR-87562-1-b.h: New file. * c-c++-common/substring-location-PR-87562-1.c: New test. * gcc.dg/plugin/diagnostic-test-string-literals-1.c: Add test for PR 87562. * gcc.dg/plugin/pr87562-a.h: New file. * gcc.dg/plugin/pr87562-b.h: New file. From-SVN: r265271 |
||
---|---|---|
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 | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
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 | ||
README | ||
symlink-tree | ||
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.