aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2012-10-18 18:47:23 +0000
committerEric Botcazou <ebotcazou@adacore.com>2012-10-18 18:47:23 +0000
commit4766ad0539872c91774a441a8d4588d4e1f3886d (patch)
tree3eaa7e6990105bcf9067c2c366f7d52001bb7487
parentf662ad198ff1443278f6e970b4fa22146ac770e6 (diff)
* c-ada-spec.c (LOCATION_COL): Delete.
(compare_location): New function. (compare_node): Use it. (compare_comment): Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@192574 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-ada-spec.c36
2 files changed, 29 insertions, 14 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index e2499fb8dbe..454196fb632 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 792fee26e19..4c47ed44a54 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;