kumquat-buildroot/package/odb/0006-Adapt-to-changes-in-GCC-8.patch

229 lines
7.0 KiB
Diff
Raw Normal View History

From aca617685045b1984c19c415a474893407578394 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Tue, 7 Nov 2017 14:58:43 +0200
Subject: [PATCH] Adapt to changes in GCC 8
[Upstream: 356630ced28f3101e8e2d88e3c52f8d3008515c7]
Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com>
---
odb/cxx-lexer.cxx | 16 ++++++++++++++--
odb/parser.cxx | 27 ++++++++++++++++++++++++++-
odb/processor.cxx | 30 ++++++++++++++++++++++--------
odb/semantics/elements.cxx | 8 ++++++++
odb/validator.cxx | 10 +++++++++-
5 files changed, 79 insertions(+), 12 deletions(-)
diff --git a/odb/cxx-lexer.cxx b/odb/cxx-lexer.cxx
index ae045d9..cfebbb5 100644
--- a/odb/cxx-lexer.cxx
+++ b/odb/cxx-lexer.cxx
@@ -93,7 +93,13 @@ next (string& token, tree* node)
// See if this is a keyword using the C++ parser machinery and
// the current C++ dialect.
//
- if (*type_ == CPP_NAME && C_IS_RESERVED_WORD (*token_))
+ if (*type_ == CPP_NAME &&
+#if BUILDING_GCC_MAJOR >= 8
+ IDENTIFIER_KEYWORD_P (*token_)
+#else
+ C_IS_RESERVED_WORD (*token_)
+#endif
+ )
*type_ = CPP_KEYWORD;
if (node != 0 && node != token_)
@@ -281,7 +287,13 @@ next (string& token, tree* node)
//
tree id (get_identifier (name));
- if (C_IS_RESERVED_WORD (id))
+ if (
+#if BUILDING_GCC_MAJOR >= 8
+ IDENTIFIER_KEYWORD_P (id)
+#else
+ C_IS_RESERVED_WORD (id)
+#endif
+ )
tt = CPP_KEYWORD;
if (node != 0)
diff --git a/odb/parser.cxx b/odb/parser.cxx
index a9d22fb..927063b 100644
--- a/odb/parser.cxx
+++ b/odb/parser.cxx
@@ -889,8 +889,23 @@ collect (tree ns)
// Traverse namespaces.
//
- for (decl = level->namespaces; decl != NULL_TREE; decl = TREE_CHAIN (decl))
+ for (
+#if BUILDING_GCC_MAJOR >= 8
+ decl = level->names;
+#else
+ decl = level->namespaces;
+#endif
+ decl != NULL_TREE;
+ decl = TREE_CHAIN (decl))
{
+#if BUILDING_GCC_MAJOR >= 8
+ // Now namespaces are interleaved with other declarations. In fact, we
+ // could probably collect everything in a single pass.
+ //
+ if (TREE_CODE (decl) != NAMESPACE_DECL)
+ continue;
+#endif
+
if (!DECL_IS_BUILTIN (decl) || DECL_NAMESPACE_STD_P (decl))
{
if (trace)
@@ -960,9 +975,15 @@ emit ()
// approximation for this namespace origin. Also resolve
// the tree node for this namespace.
//
+#if BUILDING_GCC_MAJOR >= 8
+ tree tree_node (
+ get_namespace_binding (
+ scope_->tree_node (), get_identifier (n.c_str ())));
+#else
tree tree_node (
namespace_binding (
get_identifier (n.c_str ()), scope_->tree_node ()));
+#endif
namespace_& node (unit_->new_node<namespace_> (f, l, c, tree_node));
unit_->new_edge<defines> (*scope_, node, n);
@@ -2218,7 +2239,11 @@ fq_scope (tree decl)
// If this is an inline namespace, pretend it doesn't exist.
//
+#if BUILDING_GCC_MAJOR >= 8
+ if (!is_nested_namespace (prev, scope, true))
+#else
if (!is_associated_namespace (prev, scope))
+#endif
{
tree n = DECL_NAME (scope);
diff --git a/odb/processor.cxx b/odb/processor.cxx
index 3a2cb1d..bea3624 100644
--- a/odb/processor.cxx
+++ b/odb/processor.cxx
@@ -423,12 +423,17 @@ namespace
// OVL_* macros work for both FUNCTION_DECL and OVERLOAD.
//
- for (tree o (BASELINK_FUNCTIONS (decl));
- o != 0;
- o = OVL_NEXT (o))
+#if BUILDING_GCC_MAJOR >= 8
+ for (ovl_iterator i (BASELINK_FUNCTIONS (decl)); i; ++i)
+#else
+ for (tree o (BASELINK_FUNCTIONS (decl)); o != 0; o = OVL_NEXT (o))
+#endif
{
+#if BUILDING_GCC_MAJOR >= 8
+ tree f (*i);
+#else
tree f (OVL_CURRENT (o));
-
+#endif
// We are only interested in public non-static member
// functions. Note that TREE_PUBLIC() returns something
// other than what we need.
@@ -530,12 +535,17 @@ namespace
{
// OVL_* macros work for both FUNCTION_DECL and OVERLOAD.
//
- for (tree o (BASELINK_FUNCTIONS (decl));
- o != 0;
- o = OVL_NEXT (o))
+#if BUILDING_GCC_MAJOR >= 8
+ for (ovl_iterator i (BASELINK_FUNCTIONS (decl)); i; ++i)
+#else
+ for (tree o (BASELINK_FUNCTIONS (decl)); o != 0; o = OVL_NEXT (o))
+#endif
{
+#if BUILDING_GCC_MAJOR >= 8
+ tree f (*i);
+#else
tree f (OVL_CURRENT (o));
-
+#endif
// We are only interested in non-static member functions.
//
if (!DECL_NONSTATIC_MEMBER_FUNCTION_P (f))
@@ -2934,7 +2944,11 @@ namespace
{
tree prev (CP_DECL_CONTEXT (scope));
+#if BUILDING_GCC_MAJOR >= 8
+ if (!is_nested_namespace (prev, scope, true))
+#else
if (!is_associated_namespace (prev, scope))
+#endif
break;
scope = prev;
diff --git a/odb/semantics/elements.cxx b/odb/semantics/elements.cxx
index 399d5e9..4c380d8 100644
--- a/odb/semantics/elements.cxx
+++ b/odb/semantics/elements.cxx
@@ -126,7 +126,11 @@ namespace semantics
{
tree prev (CP_DECL_CONTEXT (s));
+#if BUILDING_GCC_MAJOR >= 8
+ if (!is_nested_namespace (prev, s, true))
+#else
if (!is_associated_namespace (prev, s))
+#endif
break;
s = prev;
@@ -223,7 +227,11 @@ namespace semantics
{
// Check if this is an inline namespace and skip it if so.
//
+#if BUILDING_GCC_MAJOR >= 8
+ if (is_nested_namespace (ns, new_ns, true))
+#else
if (is_associated_namespace (ns, new_ns))
+#endif
{
// Skip also the following scope operator. Strictly speaking
// there could be none (i.e., this is a name of an inline
diff --git a/odb/validator.cxx b/odb/validator.cxx
index 91d91e5..aac52e4 100644
--- a/odb/validator.cxx
+++ b/odb/validator.cxx
@@ -520,9 +520,17 @@ namespace
// Figure out if we have a const version of the callback. OVL_*
// macros work for both FUNCTION_DECL and OVERLOAD.
//
+#if BUILDING_GCC_MAJOR >= 8
+ for (ovl_iterator i (BASELINK_FUNCTIONS (decl)); i; ++i)
+#else
for (tree o (BASELINK_FUNCTIONS (decl)); o != 0; o = OVL_NEXT (o))
+#endif
{
+#if BUILDING_GCC_MAJOR >= 8
+ tree f (*i);
+#else
tree f (OVL_CURRENT (o));
+#endif
if (DECL_CONST_MEMFUNC_P (f))
{
c.set ("callback-const", true);
@@ -1223,7 +1231,7 @@ namespace
compiler, get_identifier ("has_lt_operator"), false, false);
if (has_lt_operator_ != error_mark_node)
- has_lt_operator_ = OVL_CURRENT (has_lt_operator_);
+ has_lt_operator_ = OVL_FIRST (has_lt_operator_);
else
{
os << unit.file () << ": error: unable to resolve has_lt_operator "
--
2.25.0