aboutsummaryrefslogtreecommitdiff
path: root/odb/gcc.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-07 13:07:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-07 13:07:12 +0200
commitee9c9f3db3eb4b689e565c282345b1f49bba5042 (patch)
tree2add5cd40b963dcd0f0a6e49a96f18180c1b96e5 /odb/gcc.hxx
parent00c779a294a86c2e9ce2d2a09216e169dd69a666 (diff)
Fix to work with GCC 5
Diffstat (limited to 'odb/gcc.hxx')
-rw-r--r--odb/gcc.hxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/odb/gcc.hxx b/odb/gcc.hxx
index dc15071..504b59b 100644
--- a/odb/gcc.hxx
+++ b/odb/gcc.hxx
@@ -33,6 +33,11 @@ extern "C"
{
#endif
+// GCC's system.h below includes safe-ctype.h which "disables" versions
+// from ctype.h. Well, now it's gonna learn how it feels to be disabled.
+//
+#define SAFE_CTYPE_H
+
#include <gcc-plugin.h>
#include <config.h>
@@ -65,6 +70,34 @@ extern "C"
} // extern "C"
#endif
+// Get the value of INTEGER_CST reinterpreted as unsigned.
+//
+inline unsigned long long
+integer_value (tree n)
+{
+ unsigned long long val;
+
+#if BUILDING_GCC_MAJOR >= 5
+ if (tree_fits_uhwi_p (n))
+ val = static_cast<unsigned long long> (tree_to_uhwi (n));
+ else
+ val = static_cast<unsigned long long> (tree_to_shwi (n));
+#else
+ HOST_WIDE_INT hwl (TREE_INT_CST_LOW (n));
+ HOST_WIDE_INT hwh (TREE_INT_CST_HIGH (n));
+ unsigned short width (HOST_BITS_PER_WIDE_INT);
+
+ if (hwh == 0)
+ val = static_cast<unsigned long long> (hwl);
+ else if (hwh == -1 && hwl != 0)
+ val = static_cast<unsigned long long> (hwl);
+ else
+ val = static_cast<unsigned long long> ((hwh << width) + hwl);
+#endif
+
+ return val;
+}
+
// 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