diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-10-18 18:47:23 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-10-18 18:47:23 +0000 |
commit | 67e4210bf18a6ec35b00159b486f40f24dc02c36 (patch) | |
tree | 3eaa7e6990105bcf9067c2c366f7d52001bb7487 /gcc | |
parent | 21a11667fc0e0bbca57511f778612bf8b1b280b6 (diff) | |
download | gcc-67e4210bf18a6ec35b00159b486f40f24dc02c36.zip gcc-67e4210bf18a6ec35b00159b486f40f24dc02c36.tar.gz gcc-67e4210bf18a6ec35b00159b486f40f24dc02c36.tar.bz2 |
c-ada-spec.c (LOCATION_COL): Delete.
* c-ada-spec.c (LOCATION_COL): Delete.
(compare_location): New function.
(compare_node): Use it.
(compare_comment): Likewise.
From-SVN: r192574
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c-ada-spec.c | 36 |
2 files changed, 29 insertions, 14 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e2499fb..454196f 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2012-10-18 Eric Botcazou <ebotcazou@adacore.com> + + * c-ada-spec.c (LOCATION_COL): Delete. + (compare_location): New function. + (compare_node): Use it. + (compare_comment): Likewise. + 2012-10-16 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/53063 diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 792fee2..4c47ed4 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -67,8 +67,6 @@ static void dump_ads (const char *, void (*)(const char *), static char *to_ada_name (const char *, int *); static bool separate_class_package (tree); -#define LOCATION_COL(LOC) ((expand_location (LOC)).column) - #define INDENT(SPACE) do { \ int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0) @@ -553,6 +551,26 @@ decl_sloc (const_tree decl, bool last) return decl_sloc_common (decl, last, false); } +/* Compare two locations LHS and RHS. */ + +static int +compare_location (location_t lhs, location_t rhs) +{ + expanded_location xlhs = expand_location (lhs); + expanded_location xrhs = expand_location (rhs); + + if (xlhs.file != xrhs.file) + return filename_cmp (xlhs.file, xrhs.file); + + if (xlhs.line != xrhs.line) + return xlhs.line - xrhs.line; + + if (xlhs.column != xrhs.column) + return xlhs.column - xrhs.column; + + return 0; +} + /* Compare two declarations (LP and RP) by their source location. */ static int @@ -561,7 +579,7 @@ compare_node (const void *lp, const void *rp) const_tree lhs = *((const tree *) lp); const_tree rhs = *((const tree *) rp); - return decl_sloc (lhs, true) - decl_sloc (rhs, true); + return compare_location (decl_sloc (lhs, true), decl_sloc (rhs, true)); } /* Compare two comments (LP and RP) by their source location. */ @@ -572,17 +590,7 @@ compare_comment (const void *lp, const void *rp) const cpp_comment *lhs = (const cpp_comment *) lp; const cpp_comment *rhs = (const cpp_comment *) rp; - if (LOCATION_FILE (lhs->sloc) != LOCATION_FILE (rhs->sloc)) - return filename_cmp (LOCATION_FILE (lhs->sloc), - LOCATION_FILE (rhs->sloc)); - - if (LOCATION_LINE (lhs->sloc) != LOCATION_LINE (rhs->sloc)) - return LOCATION_LINE (lhs->sloc) - LOCATION_LINE (rhs->sloc); - - if (LOCATION_COL (lhs->sloc) != LOCATION_COL (rhs->sloc)) - return LOCATION_COL (lhs->sloc) - LOCATION_COL (rhs->sloc); - - return 0; + return compare_location (lhs->sloc, rhs->sloc); } static tree *to_dump = NULL; |