Skip to content

Commit c44b237

Browse files
committed
Update for gcc 8's removal of "namespaces" field from cp_binding_level
1 parent ab2dcf3 commit c44b237

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gcc-python-tree.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,16 @@ PyGccNamespaceDecl_declarations(tree t)
997997
return PyGcc_TreeListFromChain(cp_namespace_decls(t));
998998
}
999999

1000+
#if (GCC_VERSION >= 8000)
1001+
1002+
static int is_namespace (tree decl, void *)
1003+
{
1004+
return (TREE_CODE (decl) == NAMESPACE_DECL
1005+
&& !DECL_NAMESPACE_ALIAS (decl));
1006+
}
1007+
1008+
#endif /* #if (GCC_VERSION >= 8000) */
1009+
10001010
PyObject *
10011011
PyGccNamespaceDecl_namespaces(tree t)
10021012
{
@@ -1010,7 +1020,15 @@ PyGccNamespaceDecl_namespaces(tree t)
10101020
if (DECL_NAMESPACE_ALIAS(t))
10111021
return raise_namespace_alias("gcc.NamespaceDecl.namespaces");
10121022

1023+
/* GCC 8's r248821 (aka f7564df45462679c3b0b82f2942f5fb50b640113)
1024+
eliminated the "namespaces" field from cp_binding_level. */
1025+
1026+
#if (GCC_VERSION >= 8000)
1027+
return PyGcc_TreeListFromChainWithFilter(NAMESPACE_LEVEL(t)->names,
1028+
is_namespace, NULL);
1029+
#else
10131030
return PyGcc_TreeListFromChain(NAMESPACE_LEVEL(t)->namespaces);
1031+
#endif
10141032
}
10151033

10161034
/* Accessing the fields and methods of compound types.

0 commit comments

Comments
 (0)