aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-10-27 10:34:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-10-27 10:34:31 +0200
commit65485663ce42b92f3f4f1ea62910fd91d8ec7b29 (patch)
treecb85b8a2323b9e868f4089450936368c33cc6dba
parentef27013bab8ce027cce1c3efe4acafb8aef9d2e3 (diff)
Use expansion point rather than macro location in GCC 4.7.0 and later
-rw-r--r--odb/gcc.hxx17
-rw-r--r--odb/include.cxx2
-rw-r--r--odb/parser.cxx10
-rw-r--r--odb/pragma.cxx2
-rw-r--r--odb/processor.cxx2
5 files changed, 25 insertions, 8 deletions
diff --git a/odb/gcc.hxx b/odb/gcc.hxx
index 341b8e0..51974e4 100644
--- a/odb/gcc.hxx
+++ b/odb/gcc.hxx
@@ -65,6 +65,23 @@ extern "C"
} // extern "C"
#endif
+// Since 4.7.0 the location may point inside a macro rather than at
+// the expansion point. We are only really interested in the expansion
+// points so we use the real_source_location() wrapper rather than
+// DECL_SOURCE_LOCATION() to do this at the source.
+//
+inline location_t
+real_source_location (tree n)
+{
+ location_t l (DECL_SOURCE_LOCATION (n));
+
+#if BUILDING_GCC_MAJOR > 4 || BUILDING_GCC_MAJOR == 4 && BUILDING_GCC_MINOR > 6
+ l = linemap_resolve_location (line_table, l, LRK_MACRO_EXPANSION_POINT, 0);
+#endif
+
+ return l;
+}
+
// In 4.9.0 the tree code type was changed from int to enum tree_code.
// the tree_code_name array is also gone with the get_tree_code_name()
// function in its place.
diff --git a/odb/include.cxx b/odb/include.cxx
index cabef1e..3d3beb8 100644
--- a/odb/include.cxx
+++ b/odb/include.cxx
@@ -121,7 +121,7 @@ namespace
{
f = c.file ();
tree decl (TYPE_NAME (c.tree_node ()));
- l = DECL_SOURCE_LOCATION (decl);
+ l = real_source_location (decl);
// Any include directives that follow are trailing (specified at
// the end of the main file). Note that we ignore views in this
diff --git a/odb/parser.cxx b/odb/parser.cxx
index 6e857bb..9838a05 100644
--- a/odb/parser.cxx
+++ b/odb/parser.cxx
@@ -32,7 +32,7 @@ public:
private:
typedef semantics::access access;
- // Extended GGC tree declaration that is either a GCC tree
+ // Extended GCC tree declaration that is either a GCC tree
// declaration, a virtual declaration, or a pragma. If it is
// a pragma, then the assoc flag indicated whether this pragma
// has been associated with a declaration. Otherwise, the assoc
@@ -190,12 +190,12 @@ operator< (tree_decl const& y) const
{
location_t xloc (
decl != 0
- ? DECL_SOURCE_LOCATION (decl)
+ ? real_source_location (decl)
: (vdecl != 0 ? vdecl->loc : prag->loc));
location_t yloc (
y.decl != 0
- ? DECL_SOURCE_LOCATION (y.decl)
+ ? real_source_location (y.decl)
: (y.vdecl != 0 ? y.vdecl->loc : y.prag->loc));
return xloc < yloc;
@@ -393,7 +393,7 @@ emit_class (tree c, path const& file, size_t line, size_t clmn, bool stub)
<< "' conflicts with a previous declaration"
<< endl;
- location_t l (DECL_SOURCE_LOCATION (d));
+ location_t l (real_source_location (d));
info (l) << "'" << vd.name << "' was previously declared here"
<< endl;
@@ -860,7 +860,7 @@ collect (tree ns)
//
for (; decl != NULL_TREE; decl = TREE_CHAIN (decl))
{
- all_decls_[DECL_SOURCE_LOCATION (decl)] = decl;
+ all_decls_[real_source_location (decl)] = decl;
if (DECL_IS_BUILTIN (decl))
continue;
diff --git a/odb/pragma.cxx b/odb/pragma.cxx
index 0dc61f2..f40258f 100644
--- a/odb/pragma.cxx
+++ b/odb/pragma.cxx
@@ -3844,7 +3844,7 @@ post_process_pragmas ()
// Make sure it is instantiated.
//
tree decl (TYPE_NAME (p->value.value<tree> ()));
- location_t loc (DECL_SOURCE_LOCATION (decl));
+ location_t loc (real_source_location (decl));
// Reset input location so that we get nice diagnostics in case
// of an error.
diff --git a/odb/processor.cxx b/odb/processor.cxx
index cdfd883..291dcd3 100644
--- a/odb/processor.cxx
+++ b/odb/processor.cxx
@@ -444,7 +444,7 @@ namespace
// Update the location of the access expression to point
// to this function.
//
- ma.loc = location (DECL_SOURCE_LOCATION (f));
+ ma.loc = location (real_source_location (f));
found = r;
}
}