From 356630ced28f3101e8e2d88e3c52f8d3008515c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Nov 2017 14:58:43 +0200 Subject: Adapt to changes in GCC 8 --- 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 72ebd0b..cb71740 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 79a5bc2..304be98 100644 --- a/odb/parser.cxx +++ b/odb/parser.cxx @@ -911,8 +911,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) @@ -986,9 +1001,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 (f, l, c, tree_node)); unit_->new_edge (*scope_, node, n); @@ -2244,7 +2265,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 7c396e7..0a6d753 100644 --- a/odb/processor.cxx +++ b/odb/processor.cxx @@ -444,12 +444,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. @@ -551,12 +556,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)) @@ -2880,7 +2890,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 a907dd5..b2df56f 100644 --- a/odb/semantics/elements.cxx +++ b/odb/semantics/elements.cxx @@ -143,7 +143,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; @@ -240,7 +244,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 cd22548..75757cd 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -560,9 +560,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); @@ -1504,7 +1512,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 " -- cgit v1.1