hc
2024-08-19 eb6b9ee90f50f13c5abb885ce483802d6262f2b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
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