diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-02-23 17:44:28 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-02-23 17:44:28 +0000 |
commit | 196440f844be32600507b6a026bca318675d5cd0 (patch) | |
tree | 6c0de6232fb3db3c73408db9d8aeaa7ce4297065 | |
parent | 1d3121af3ad1eb7eb240b0b949d4b57415497463 (diff) | |
download | gcc-196440f844be32600507b6a026bca318675d5cd0.zip gcc-196440f844be32600507b6a026bca318675d5cd0.tar.gz gcc-196440f844be32600507b6a026bca318675d5cd0.tar.bz2 |
PR preprocessor/69126: avoid comparing ad-hoc and non-ad-hoc locations
gcc/testsuite/ChangeLog:
PR preprocessor/69126
PR preprocessor/69543
* c-c++-common/pr69126-2-long.c: New test.
* c-c++-common/pr69126-2-short.c: New test.
* c-c++-common/pr69543-1.c: Remove xfail.
libcpp/ChangeLog:
PR preprocessor/69126
PR preprocessor/69543
* line-map.c (linemap_compare_locations): At the function top,
replace inlined bodies of get_location_from_adhoc_loc with calls
to get_location_from_adhoc_loc. Add a pair of calls to
get_location_from_adhoc_loc at the bottom of the function, to
avoid meaningless comparisons of ad-hoc and non-ad-hoc locations.
From-SVN: r233638
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr69126-2-long.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr69126-2-short.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr69543-1.c | 4 | ||||
-rw-r--r-- | libcpp/ChangeLog | 10 | ||||
-rw-r--r-- | libcpp/line-map.c | 9 |
6 files changed, 48 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96007ce..d6aa9fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -2,6 +2,14 @@ PR preprocessor/69126 PR preprocessor/69543 + * c-c++-common/pr69126-2-long.c: New test. + * c-c++-common/pr69126-2-short.c: New test. + * c-c++-common/pr69543-1.c: Remove xfail. + +2016-02-23 David Malcolm <dmalcolm@redhat.com> + + PR preprocessor/69126 + PR preprocessor/69543 PR preprocessor/69558 * c-c++-common/pr69126.c (MACRO_1, test_1): New. (f): Rename to... diff --git a/gcc/testsuite/c-c++-common/pr69126-2-long.c b/gcc/testsuite/c-c++-common/pr69126-2-long.c new file mode 100644 index 0000000..f4f1964 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr69126-2-long.c @@ -0,0 +1,11 @@ +/* { dg-options "-Wdeprecated-declarations" } */ + +/* The macro's name is >= 32 characters long, and hence its location + requires an ad-hoc location. */ + +#define IGNORE_WHERE_MACRO_IS_LONGER_THAN_31_CHARS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +__attribute__((deprecated)) void f(); +int main() { + IGNORE_WHERE_MACRO_IS_LONGER_THAN_31_CHARS + f(); +} diff --git a/gcc/testsuite/c-c++-common/pr69126-2-short.c b/gcc/testsuite/c-c++-common/pr69126-2-short.c new file mode 100644 index 0000000..aee43e5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr69126-2-short.c @@ -0,0 +1,11 @@ +/* { dg-options "-Wdeprecated-declarations" } */ + +/* IGNORE_SHORT_MACRO is < 32 characters long, and hence its location + can be stored without needing an ad-hoc location. */ + +#define IGNORE_SHORT_MACRO _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +__attribute__((deprecated)) void f(); +int main() { + IGNORE_SHORT_MACRO + f(); +} diff --git a/gcc/testsuite/c-c++-common/pr69543-1.c b/gcc/testsuite/c-c++-common/pr69543-1.c index bfb5270..bbf4759 100644 --- a/gcc/testsuite/c-c++-common/pr69543-1.c +++ b/gcc/testsuite/c-c++-common/pr69543-1.c @@ -3,8 +3,6 @@ /* Verify disabling a warning, where the _Pragma is within a macro, but the affected code is *not* in a macro. */ -/* TODO: XFAIL: why does g++ still emit a warning here? (works for C). */ - # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ @@ -16,6 +14,6 @@ void test (char yylval) { char *yyvsp; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; /* { dg-bogus "used uninitialized" "" { xfail { c++ } } } */ + *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END } diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index a5cef17..1dfcf8d 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,13 @@ +2016-02-23 David Malcolm <dmalcolm@redhat.com> + + PR preprocessor/69126 + PR preprocessor/69543 + * line-map.c (linemap_compare_locations): At the function top, + replace inlined bodies of get_location_from_adhoc_loc with calls + to get_location_from_adhoc_loc. Add a pair of calls to + get_location_from_adhoc_loc at the bottom of the function, to + avoid meaningless comparisons of ad-hoc and non-ad-hoc locations. + 2016-02-08 David Malcolm <dmalcolm@redhat.com> PR preprocessor/69664 diff --git a/libcpp/line-map.c b/libcpp/line-map.c index e9175df..c05a001 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -1328,9 +1328,9 @@ linemap_compare_locations (struct line_maps *set, source_location l0 = pre, l1 = post; if (IS_ADHOC_LOC (l0)) - l0 = set->location_adhoc_data_map.data[l0 & MAX_SOURCE_LOCATION].locus; + l0 = get_location_from_adhoc_loc (set, l0); if (IS_ADHOC_LOC (l1)) - l1 = set->location_adhoc_data_map.data[l1 & MAX_SOURCE_LOCATION].locus; + l1 = get_location_from_adhoc_loc (set, l1); if (l0 == l1) return 0; @@ -1365,6 +1365,11 @@ linemap_compare_locations (struct line_maps *set, return i1 - i0; } + if (IS_ADHOC_LOC (l0)) + l0 = get_location_from_adhoc_loc (set, l0); + if (IS_ADHOC_LOC (l1)) + l1 = get_location_from_adhoc_loc (set, l1); + return l1 - l0; } |