diff options
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 6 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index fa2fa7d97e8..355b4cb0f73 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2019-02-20 David Malcolm <dmalcolm@redhat.com> + + PR c/89410 + * include/line-map.h (linenum_arith_t): New typedef. + (compare): Use it. + 2019-02-18 Martin Liska <mliska@suse.cz> PR c++/89383 diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index a6eb87c2ec0..6c77c288855 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -49,13 +49,16 @@ along with this program; see the file COPYING3. If not see /* The type of line numbers. */ typedef unsigned int linenum_type; +/* A type for doing arithmetic on line numbers. */ +typedef long long linenum_arith_t; + /* A function for for use by qsort for comparing line numbers. */ inline int compare (linenum_type lhs, linenum_type rhs) { - /* Avoid truncation issues by using long long for the comparison, + /* Avoid truncation issues by using linenum_arith_t for the comparison, and only consider the sign of the result. */ - long long diff = (long long)lhs - (long long)rhs; + linenum_arith_t diff = (linenum_arith_t)lhs - (linenum_arith_t)rhs; if (diff) return diff > 0 ? 1 : -1; return 0; |