aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-11-09 11:09:42 -0500
committerPatrick Palka <ppalka@redhat.com>2020-11-09 11:09:42 -0500
commit4394b1ce7731b04446555e034163b14b4f4a7f8d (patch)
treeddb92ae849196b286c709c15b7f8ff96b13771c2 /gcc/cp/parser.c
parentc5395d88dfa2123ca5155008c8c8339ded98fd32 (diff)
downloadgcc-4394b1ce7731b04446555e034163b14b4f4a7f8d.zip
gcc-4394b1ce7731b04446555e034163b14b4f4a7f8d.tar.gz
gcc-4394b1ce7731b04446555e034163b14b4f4a7f8d.tar.bz2
c-family: Fix regression in location-overflow-test-1.c [PR97117]
The r11-3266 patch that added macro support to -Wmisleading-indentation accidentally suppressed the column-tracking diagnostic in get_visual_column in some cases, e.g. in the location-overflow-test-1.c testcase. More generally, when all three tokens are on the same line and we've run out of locations with column info, then their location_t values will be equal, and we exit early from should_warn_for_misleading_indentation due to the new check /* Give up if the loci are not all distinct. */ if (guard_loc == body_loc || body_loc == next_stmt_loc) return false; before we ever call get_visual_column. [ This new check is needed to detect and give up on analyzing code fragments where exactly two out of the three tokens come from the same macro expansion, e.g. #define MACRO \ if (a) \ foo (); MACRO; bar (); Here, guard_loc and body_loc will be equal and point to the macro expansion point (and next_stmt_loc will point to 'bar'). The heuristics that the warning uses are not really valid in scenarios like these. ] In order to restore the column-tracking diagnostic, this patch moves the the diagnostic code out from get_visual_column to earlier in should_warn_for_misleading_indentation. Moreover, it tests the three locations for a zero column all at once, which I suppose should make us issue the diagnostic more consistently. gcc/c-family/ChangeLog: PR testsuite/97117 * c-indentation.c (get_visual_column): Remove location_t parameter. Move the column-tracking diagnostic code from here to ... (should_warn_for_misleading_indentation): ... here, before the early exit for when the loci are not all distinct. Don't pass a location_t argument to get_visual_column. (assert_get_visual_column_succeeds): Don't pass a location_t argument to get_visual_column. (assert_get_visual_column_fails): Likewise.
Diffstat (limited to 'gcc/cp/parser.c')
0 files changed, 0 insertions, 0 deletions