diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-21 15:50:38 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-21 15:50:38 +0000 |
commit | 8df44fbf7f4788ef56a3b792cbb833b654392d7c (patch) | |
tree | e310cae0dff43fc2c619bb7bf0b1a055a547085e /gcc/input.c | |
parent | 64a8c4a7645f69350486c97f7dcebe3d39d2ebee (diff) | |
download | gcc-8df44fbf7f4788ef56a3b792cbb833b654392d7c.tar.gz |
substring_loc info needs default track-macro-expansion (PR preprocessor/78324)
gcc/ChangeLog:
PR preprocessor/78324
* input.c (get_substring_ranges_for_loc): Fail gracefully if
-ftrack-macro-expansion has a value other than 2.
gcc/testsuite/ChangeLog:
PR preprocessor/78324
* gcc.dg/plugin/diagnostic-test-string-literals-1.c
(test_multitoken_macro): New function.
* gcc.dg/plugin/diagnostic-test-string-literals-3.c: New test
case.
* gcc.dg/plugin/diagnostic-test-string-literals-4.c: New test
case.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the new test
cases.
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (test_sprintf_note):
Move to...
* gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: ...here. Drop
-ftrack-macro-expansion=0.
(test_sprintf_note): Remove "P" macro. Add
dg-begin/end-multiline-output directives.
(LINE, buffer, ptr): Copy from builtin-sprintf-warn-1.c.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242667 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/input.c')
-rw-r--r-- | gcc/input.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/input.c b/gcc/input.c index 728f4dd65d7..611e18b541e 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -1322,6 +1322,15 @@ get_substring_ranges_for_loc (cpp_reader *pfile, if (strloc == UNKNOWN_LOCATION) return "unknown location"; + /* Reparsing the strings requires accurate location information. + If -ftrack-macro-expansion has been overridden from its default + of 2, then we might have a location of a macro expansion point, + rather than the location of the literal itself. + Avoid this by requiring that we have full macro expansion tracking + for substring locations to be available. */ + if (cpp_get_options (pfile)->track_macro_expansion != 2) + return "track_macro_expansion != 2"; + /* 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. */ |