gccint: Namespaces
1
1 11.10.2 Namespaces
1 ------------------
1
1 The root of the entire intermediate representation is the variable
1 'global_namespace'. This is the namespace specified with '::' in C++
1 source code. All other namespaces, types, variables, functions, and so
1 forth can be found starting with this namespace.
1
1 However, except for the fact that it is distinguished as the root of
1 the representation, the global namespace is no different from any other
1 namespace. Thus, in what follows, we describe namespaces generally,
1 rather than the global namespace in particular.
1
1 A namespace is represented by a 'NAMESPACE_DECL' node.
1
1 The following macros and functions can be used on a 'NAMESPACE_DECL':
1
1 'DECL_NAME'
1 This macro is used to obtain the 'IDENTIFIER_NODE' corresponding to
11 the unqualified name of the name of the namespace (⇒
Identifiers). The name of the global namespace is '::', even
1 though in C++ the global namespace is unnamed. However, you should
1 use comparison with 'global_namespace', rather than 'DECL_NAME' to
1 determine whether or not a namespace is the global one. An unnamed
1 namespace will have a 'DECL_NAME' equal to
1 'anonymous_namespace_name'. Within a single translation unit, all
1 unnamed namespaces will have the same name.
1
1 'DECL_CONTEXT'
1 This macro returns the enclosing namespace. The 'DECL_CONTEXT' for
1 the 'global_namespace' is 'NULL_TREE'.
1
1 'DECL_NAMESPACE_ALIAS'
1 If this declaration is for a namespace alias, then
1 'DECL_NAMESPACE_ALIAS' is the namespace for which this one is an
1 alias.
1
1 Do not attempt to use 'cp_namespace_decls' for a namespace which is
1 an alias. Instead, follow 'DECL_NAMESPACE_ALIAS' links until you
1 reach an ordinary, non-alias, namespace, and call
1 'cp_namespace_decls' there.
1
1 'DECL_NAMESPACE_STD_P'
1 This predicate holds if the namespace is the special '::std'
1 namespace.
1
1 'cp_namespace_decls'
1 This function will return the declarations contained in the
1 namespace, including types, overloaded functions, other namespaces,
1 and so forth. If there are no declarations, this function will
1 return 'NULL_TREE'. The declarations are connected through their
1 'TREE_CHAIN' fields.
1
1 Although most entries on this list will be declarations,
1 'TREE_LIST' nodes may also appear. In this case, the 'TREE_VALUE'
1 will be an 'OVERLOAD'. The value of the 'TREE_PURPOSE' is
1 unspecified; back ends should ignore this value. As with the other
1 kinds of declarations returned by 'cp_namespace_decls', the
1 'TREE_CHAIN' will point to the next declaration in this list.
1
1 For more information on the kinds of declarations that can occur on
1 this list, ⇒Declarations. Some declarations will not appear
1 on this list. In particular, no 'FIELD_DECL', 'LABEL_DECL', or
1 'PARM_DECL' nodes will appear here.
1
1 This function cannot be used with namespaces that have
1 'DECL_NAMESPACE_ALIAS' set.
1