diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-03-17 18:27:47 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-03-17 18:27:47 +0000 |
commit | ded6091379ad0d03bf5ea26633d501b026615c09 (patch) | |
tree | 50eca93808fd6cb6a328f1c827549ccd995c143d | |
parent | 17366700d4ddcefeb271677029f59646a37a8ed3 (diff) | |
download | gcc-ded6091379ad0d03bf5ea26633d501b026615c09.zip gcc-ded6091379ad0d03bf5ea26633d501b026615c09.tar.gz gcc-ded6091379ad0d03bf5ea26633d501b026615c09.tar.bz2 |
PR c/70264: fix crash in compatible_locations_p with BUILTINS_LOCATION
In r234088 my fix for PR c++/70105 didn't allow for the possibility that
when comparing a pair of macro expansion histories that one of the
macros in the history might not be located within a line-map, and
PR c/70264 reports a crash due to encountering BUILTINS_LOCATION within
the traversal.
Fixed thusly.
Successfully bootstrapped on x86_64-pc-linux-gnu; adds 4 PASS results
to gcc.sum and 12 to g++.sum.
gcc/ChangeLog:
PR c/70264
* diagnostic-show-locus.c (compatible_locations_p): Handle the case
where one or both locations aren't within a line_map.
gcc/testsuite/ChangeLog:
PR c/70264
* c-c++-common/pr70264.c: New test case.
From-SVN: r234303
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/diagnostic-show-locus.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr70264.c | 13 |
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b7711b8..4a74494 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-03-17 David Malcolm <dmalcolm@redhat.com> + + PR c/70264 + * diagnostic-show-locus.c (compatible_locations_p): Handle the case + where one or both locations aren't within a line_map. + 2016-03-17 H.J. Lu <hongjiu.lu@intel.com> PR driver/70192 diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index f10ade5..bf95666 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -486,6 +486,12 @@ compatible_locations_p (location_t loc_a, location_t loc_b) if (IS_ADHOC_LOC (loc_b)) loc_b = get_location_from_adhoc_loc (line_table, loc_b); + /* If either location is one of the special locations outside of a + linemap, they are only compatible if they are equal. */ + if (loc_a < RESERVED_LOCATION_COUNT + || loc_b < RESERVED_LOCATION_COUNT) + return loc_a == loc_b; + const line_map *map_a = linemap_lookup (line_table, loc_a); linemap_assert (map_a); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7fe7295..b3c16b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-03-17 David Malcolm <dmalcolm@redhat.com> + + PR c/70264 + * c-c++-common/pr70264.c: New test case. + 2016-03-17 Jakub Jelinek <jakub@redhat.com> PR c++/70144 diff --git a/gcc/testsuite/c-c++-common/pr70264.c b/gcc/testsuite/c-c++-common/pr70264.c new file mode 100644 index 0000000..815aad1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr70264.c @@ -0,0 +1,13 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +#define X __LINE__ /* { dg-error "expected" } */ +X + +/* { dg-begin-multiline-output "" } + #define X __LINE__ + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + X + ^ + { dg-end-multiline-output "" } */ |