summaryrefslogtreecommitdiff
path: root/gcc/input.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-11-30 01:13:37 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-11-30 01:13:37 +0000
commit94f597df228750eec6d5c28134edd45022b0394a (patch)
tree977d5229cdf9b708bbd2e09cc532aab26e12f656 /gcc/input.c
parent3517d13be77399582c2068eb2c26881864ed110e (diff)
substring locations and # line directives (PR preprocessor/78569)
The ICE in PR preprocessor/78569 appears to be due to an attempt to generate substring locations in a .i file where the underlying .c file has changed since the .i file was generated. This can't work, so it seems safest for the on-demand substring locations to be unavailable for such files, falling back to "whole string" locations for such cases. gcc/ChangeLog: PR preprocessor/78569 * input.c (get_substring_ranges_for_loc): Fail gracefully if line directives were present. gcc/testsuite/ChangeLog: PR preprocessor/78569 * gcc.dg/format/pr78569.c: New test case. From-SVN: r242990
Diffstat (limited to 'gcc/input.c')
-rw-r--r--gcc/input.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/input.c b/gcc/input.c
index 611e18b541e..1c7228a0080 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -1331,6 +1331,16 @@ get_substring_ranges_for_loc (cpp_reader *pfile,
if (cpp_get_options (pfile)->track_macro_expansion != 2)
return "track_macro_expansion != 2";
+ /* If #line or # 44 "file"-style directives are present, then there's
+ no guarantee that the line numbers we have can be used to locate
+ the strings. For example, we might have a .i file with # directives
+ pointing back to lines within a .c file, but the .c file might
+ have been edited since the .i file was created.
+ In such a case, the safest course is to disable on-demand substring
+ locations. */
+ if (line_table->seen_line_directive)
+ return "seen line directive";
+
/* If string concatenation has occurred at STRLOC, get the locations
of all of the literal tokens making up the compound string.
Otherwise, just use STRLOC. */