0006-Adapt-to-changes-in-GCC-8.patch 7.0 KB

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