1From aca617685045b1984c19c415a474893407578394 Mon Sep 17 00:00:00 2001 2From: Boris Kolpackov <boris@codesynthesis.com> 3Date: Tue, 7 Nov 2017 14:58:43 +0200 4Subject: [PATCH] Adapt to changes in GCC 8 5 6[Upstream: 356630ced28f3101e8e2d88e3c52f8d3008515c7] 7Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com> 8--- 9 odb/cxx-lexer.cxx | 16 ++++++++++++++-- 10 odb/parser.cxx | 27 ++++++++++++++++++++++++++- 11 odb/processor.cxx | 30 ++++++++++++++++++++++-------- 12 odb/semantics/elements.cxx | 8 ++++++++ 13 odb/validator.cxx | 10 +++++++++- 14 5 files changed, 79 insertions(+), 12 deletions(-) 15 16diff --git a/odb/cxx-lexer.cxx b/odb/cxx-lexer.cxx 17index ae045d9..cfebbb5 100644 18--- a/odb/cxx-lexer.cxx 19+++ b/odb/cxx-lexer.cxx 20@@ -93,7 +93,13 @@ next (string& token, tree* node) 21 // See if this is a keyword using the C++ parser machinery and 22 // the current C++ dialect. 23 // 24- if (*type_ == CPP_NAME && C_IS_RESERVED_WORD (*token_)) 25+ if (*type_ == CPP_NAME && 26+#if BUILDING_GCC_MAJOR >= 8 27+ IDENTIFIER_KEYWORD_P (*token_) 28+#else 29+ C_IS_RESERVED_WORD (*token_) 30+#endif 31+ ) 32 *type_ = CPP_KEYWORD; 33 34 if (node != 0 && node != token_) 35@@ -281,7 +287,13 @@ next (string& token, tree* node) 36 // 37 tree id (get_identifier (name)); 38 39- if (C_IS_RESERVED_WORD (id)) 40+ if ( 41+#if BUILDING_GCC_MAJOR >= 8 42+ IDENTIFIER_KEYWORD_P (id) 43+#else 44+ C_IS_RESERVED_WORD (id) 45+#endif 46+ ) 47 tt = CPP_KEYWORD; 48 49 if (node != 0) 50diff --git a/odb/parser.cxx b/odb/parser.cxx 51index a9d22fb..927063b 100644 52--- a/odb/parser.cxx 53+++ b/odb/parser.cxx 54@@ -889,8 +889,23 @@ collect (tree ns) 55 56 // Traverse namespaces. 57 // 58- for (decl = level->namespaces; decl != NULL_TREE; decl = TREE_CHAIN (decl)) 59+ for ( 60+#if BUILDING_GCC_MAJOR >= 8 61+ decl = level->names; 62+#else 63+ decl = level->namespaces; 64+#endif 65+ decl != NULL_TREE; 66+ decl = TREE_CHAIN (decl)) 67 { 68+#if BUILDING_GCC_MAJOR >= 8 69+ // Now namespaces are interleaved with other declarations. In fact, we 70+ // could probably collect everything in a single pass. 71+ // 72+ if (TREE_CODE (decl) != NAMESPACE_DECL) 73+ continue; 74+#endif 75+ 76 if (!DECL_IS_BUILTIN (decl) || DECL_NAMESPACE_STD_P (decl)) 77 { 78 if (trace) 79@@ -960,9 +975,15 @@ emit () 80 // approximation for this namespace origin. Also resolve 81 // the tree node for this namespace. 82 // 83+#if BUILDING_GCC_MAJOR >= 8 84+ tree tree_node ( 85+ get_namespace_binding ( 86+ scope_->tree_node (), get_identifier (n.c_str ()))); 87+#else 88 tree tree_node ( 89 namespace_binding ( 90 get_identifier (n.c_str ()), scope_->tree_node ())); 91+#endif 92 93 namespace_& node (unit_->new_node<namespace_> (f, l, c, tree_node)); 94 unit_->new_edge<defines> (*scope_, node, n); 95@@ -2218,7 +2239,11 @@ fq_scope (tree decl) 96 97 // If this is an inline namespace, pretend it doesn't exist. 98 // 99+#if BUILDING_GCC_MAJOR >= 8 100+ if (!is_nested_namespace (prev, scope, true)) 101+#else 102 if (!is_associated_namespace (prev, scope)) 103+#endif 104 { 105 tree n = DECL_NAME (scope); 106 107diff --git a/odb/processor.cxx b/odb/processor.cxx 108index 3a2cb1d..bea3624 100644 109--- a/odb/processor.cxx 110+++ b/odb/processor.cxx 111@@ -423,12 +423,17 @@ namespace 112 113 // OVL_* macros work for both FUNCTION_DECL and OVERLOAD. 114 // 115- for (tree o (BASELINK_FUNCTIONS (decl)); 116- o != 0; 117- o = OVL_NEXT (o)) 118+#if BUILDING_GCC_MAJOR >= 8 119+ for (ovl_iterator i (BASELINK_FUNCTIONS (decl)); i; ++i) 120+#else 121+ for (tree o (BASELINK_FUNCTIONS (decl)); o != 0; o = OVL_NEXT (o)) 122+#endif 123 { 124+#if BUILDING_GCC_MAJOR >= 8 125+ tree f (*i); 126+#else 127 tree f (OVL_CURRENT (o)); 128- 129+#endif 130 // We are only interested in public non-static member 131 // functions. Note that TREE_PUBLIC() returns something 132 // other than what we need. 133@@ -530,12 +535,17 @@ namespace 134 { 135 // OVL_* macros work for both FUNCTION_DECL and OVERLOAD. 136 // 137- for (tree o (BASELINK_FUNCTIONS (decl)); 138- o != 0; 139- o = OVL_NEXT (o)) 140+#if BUILDING_GCC_MAJOR >= 8 141+ for (ovl_iterator i (BASELINK_FUNCTIONS (decl)); i; ++i) 142+#else 143+ for (tree o (BASELINK_FUNCTIONS (decl)); o != 0; o = OVL_NEXT (o)) 144+#endif 145 { 146+#if BUILDING_GCC_MAJOR >= 8 147+ tree f (*i); 148+#else 149 tree f (OVL_CURRENT (o)); 150- 151+#endif 152 // We are only interested in non-static member functions. 153 // 154 if (!DECL_NONSTATIC_MEMBER_FUNCTION_P (f)) 155@@ -2934,7 +2944,11 @@ namespace 156 { 157 tree prev (CP_DECL_CONTEXT (scope)); 158 159+#if BUILDING_GCC_MAJOR >= 8 160+ if (!is_nested_namespace (prev, scope, true)) 161+#else 162 if (!is_associated_namespace (prev, scope)) 163+#endif 164 break; 165 166 scope = prev; 167diff --git a/odb/semantics/elements.cxx b/odb/semantics/elements.cxx 168index 399d5e9..4c380d8 100644 169--- a/odb/semantics/elements.cxx 170+++ b/odb/semantics/elements.cxx 171@@ -126,7 +126,11 @@ namespace semantics 172 { 173 tree prev (CP_DECL_CONTEXT (s)); 174 175+#if BUILDING_GCC_MAJOR >= 8 176+ if (!is_nested_namespace (prev, s, true)) 177+#else 178 if (!is_associated_namespace (prev, s)) 179+#endif 180 break; 181 182 s = prev; 183@@ -223,7 +227,11 @@ namespace semantics 184 { 185 // Check if this is an inline namespace and skip it if so. 186 // 187+#if BUILDING_GCC_MAJOR >= 8 188+ if (is_nested_namespace (ns, new_ns, true)) 189+#else 190 if (is_associated_namespace (ns, new_ns)) 191+#endif 192 { 193 // Skip also the following scope operator. Strictly speaking 194 // there could be none (i.e., this is a name of an inline 195diff --git a/odb/validator.cxx b/odb/validator.cxx 196index 91d91e5..aac52e4 100644 197--- a/odb/validator.cxx 198+++ b/odb/validator.cxx 199@@ -520,9 +520,17 @@ namespace 200 // Figure out if we have a const version of the callback. OVL_* 201 // macros work for both FUNCTION_DECL and OVERLOAD. 202 // 203+#if BUILDING_GCC_MAJOR >= 8 204+ for (ovl_iterator i (BASELINK_FUNCTIONS (decl)); i; ++i) 205+#else 206 for (tree o (BASELINK_FUNCTIONS (decl)); o != 0; o = OVL_NEXT (o)) 207+#endif 208 { 209+#if BUILDING_GCC_MAJOR >= 8 210+ tree f (*i); 211+#else 212 tree f (OVL_CURRENT (o)); 213+#endif 214 if (DECL_CONST_MEMFUNC_P (f)) 215 { 216 c.set ("callback-const", true); 217@@ -1223,7 +1231,7 @@ namespace 218 compiler, get_identifier ("has_lt_operator"), false, false); 219 220 if (has_lt_operator_ != error_mark_node) 221- has_lt_operator_ = OVL_CURRENT (has_lt_operator_); 222+ has_lt_operator_ = OVL_FIRST (has_lt_operator_); 223 else 224 { 225 os << unit.file () << ": error: unable to resolve has_lt_operator " 226-- 2272.25.0 228 229