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