From 26a67918a501370a8fe62db18a74761a0073016f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 15 Sep 2017 17:40:33 +0100 Subject: [PATCH] Sync libiberty/ & include/ with GCC Note this brings in the interface files for libcc1/G++ as well, which we will be needing in GDB soon anyway. That commit renamed a method in the C interface and that required a small update to GDB's compile/ code, which I've included that in this patch to keep the tree building. include/ChangeLog: 2017-09-15 Pedro Alves * ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro. 2017-09-12 Jiong Wang * dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP. * dwarf2.h (DW_CFA_DUP): New define. 2017-08-21 Richard Biener * simple-object.h (simple_object_copy_lto_debug_sections): New function. 2017-05-18 Martin Liska * ansidecl.h: Define CONSTEXPR macro. 2017-05-24 Nathan Sidwell * libiberty.h (ASTRDUP): Adjust cast to avoid warning. 2017-01-30 Alexandre Oliva Introduce C++ support in libcc1. * gcc-c-fe.def (int_type_v0): Rename from... (int_type): ... this. Introduce new version. (float_type_v0): Rename from... (float_type): ... this. Introduce new version. (char_type): New. * gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1. (gcc_type_array): Move... * gcc-interface.h: ... here. * gcc-cp-fe.def: New. * gcc-cp-interface.h: New. 2016-04-29 Oleg Endo * longlong.h (umul_ppmm): Remove SHMEDIA checks. (__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations. 2017-09-15 Yao Qi Pedro Alves * ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro. 2017-09-12 Jiong Wang * dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP. * dwarf2.h (DW_CFA_DUP): New define. 2017-08-21 Richard Biener * simple-object.h (simple_object_copy_lto_debug_sections): New function. 2017-05-18 Martin Liska * ansidecl.h: Define CONSTEXPR macro. 2017-05-24 Nathan Sidwell * libiberty.h (ASTRDUP): Adjust cast to avoid warning. 2017-01-30 Alexandre Oliva Introduce C++ support in libcc1. * gcc-c-fe.def (int_type_v0): Rename from... (int_type): ... this. Introduce new version. (float_type_v0): Rename from... (float_type): ... this. Introduce new version. (char_type): New. * gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1. (gcc_type_array): Move... * gcc-interface.h: ... here. * gcc-cp-fe.def: New. * gcc-cp-interface.h: New. 2016-04-29 Oleg Endo * longlong.h (umul_ppmm): Remove SHMEDIA checks. (__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations. libiberty/ChangeLog: 2017-09-15 Nathan Sidwell PR demangler/82195 * cp-demangle.c (d_name): Add 'toplevel' parm. Pass to ... (d_local_name): ... here. Parse trailing function args on nested local_name. (d_encoding, d_special_name, d_class_enum_type): Adjust d_name calls. * testsuite/demangle-expected: Add tests. 2017-09-15 Richard Biener PR lto/81968 * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections): Iterate marking dependent sections necessary. 2017-09-15 Nathan Sidwell * cp-demangle.c (is_fnqual_component_type): Reimplement using FNQUAL_COMPONENT_CASE. (d_encoding): Hold bare_function_type in local var. (d_local_name): Build name in both cases and build result once. Collapse switch-if to single conditional. (d_local_name): * testsuite/demangle-expected: Realign blank lines with tests. 2017-09-12 Jiong Wang * dwarfnames.c (DW_CFA_DUP): New define. gdb/ChangeLog: 2017-09-15 Pedro Alves * compile/compile-c-types.c (convert_enum, convert_int) (convert_float): Adjust to refer to int_type_v0 and float_type_v0. --- gdb/ChangeLog | 5 + gdb/compile/compile-c-types.c | 16 +- include/ChangeLog | 88 +++ include/ansidecl.h | 34 +- include/dwarf2.def | 1 + include/dwarf2.h | 2 + include/gcc-c-fe.def | 35 +- include/gcc-c-interface.h | 21 +- include/gcc-cp-fe.def | 1050 +++++++++++++++++++++++++ include/gcc-cp-interface.h | 496 ++++++++++++ include/gcc-interface.h | 14 + include/libiberty.h | 4 +- include/longlong.h | 65 +- include/simple-object.h | 8 + libiberty/ChangeLog | 30 + libiberty/cp-demangle.c | 110 +-- libiberty/dwarfnames.c | 2 + libiberty/simple-object-elf.c | 122 +-- libiberty/testsuite/demangle-expected | 21 +- 19 files changed, 1929 insertions(+), 195 deletions(-) create mode 100644 include/gcc-cp-fe.def create mode 100644 include/gcc-cp-interface.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 86f1fb81bc..c4f55a8137 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-09-15 Pedro Alves + + * compile/compile-c-types.c (convert_enum, convert_int) + (convert_float): Adjust to refer to int_type_v0 and float_type_v0. + 2017-09-15 Simon Marchi * dwarf2read.c (copy_string): Remove. diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index b53a3c45dc..853342952d 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -207,9 +207,9 @@ convert_enum (struct compile_c_instance *context, struct type *type) int i; struct gcc_c_context *ctx = C_CTX (context); - int_type = ctx->c_ops->int_type (ctx, - TYPE_UNSIGNED (type), - TYPE_LENGTH (type)); + int_type = ctx->c_ops->int_type_v0 (ctx, + TYPE_UNSIGNED (type), + TYPE_LENGTH (type)); result = ctx->c_ops->build_enum_type (ctx, int_type); for (i = 0; i < TYPE_NFIELDS (type); ++i) @@ -273,9 +273,9 @@ convert_func (struct compile_c_instance *context, struct type *type) static gcc_type convert_int (struct compile_c_instance *context, struct type *type) { - return C_CTX (context)->c_ops->int_type (C_CTX (context), - TYPE_UNSIGNED (type), - TYPE_LENGTH (type)); + return C_CTX (context)->c_ops->int_type_v0 (C_CTX (context), + TYPE_UNSIGNED (type), + TYPE_LENGTH (type)); } /* Convert a floating-point type to its gcc representation. */ @@ -283,8 +283,8 @@ convert_int (struct compile_c_instance *context, struct type *type) static gcc_type convert_float (struct compile_c_instance *context, struct type *type) { - return C_CTX (context)->c_ops->float_type (C_CTX (context), - TYPE_LENGTH (type)); + return C_CTX (context)->c_ops->float_type_v0 (C_CTX (context), + TYPE_LENGTH (type)); } /* Convert the 'void' type to its gcc representation. */ diff --git a/include/ChangeLog b/include/ChangeLog index 3b6cea9664..1ba7de3c6a 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,91 @@ +2017-09-15 Pedro Alves + + Sync with mainline gcc sources (r252823) + + 2017-09-15 Yao Qi + Pedro Alves + + * ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro. + + 2017-09-12 Jiong Wang + + * dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP. + * dwarf2.h (DW_CFA_DUP): New define. + + 2017-08-21 Richard Biener + + * simple-object.h (simple_object_copy_lto_debug_sections): New + function. + + 2017-05-18 Martin Liska + + * ansidecl.h: Define CONSTEXPR macro. + + 2017-05-24 Nathan Sidwell + + * libiberty.h (ASTRDUP): Adjust cast to avoid warning. + + 2017-01-30 Alexandre Oliva + + Introduce C++ support in libcc1. + * gcc-c-fe.def (int_type_v0): Rename from... + (int_type): ... this. Introduce new version. + (float_type_v0): Rename from... + (float_type): ... this. Introduce new version. + (char_type): New. + * gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1. + (gcc_type_array): Move... + * gcc-interface.h: ... here. + * gcc-cp-fe.def: New. + * gcc-cp-interface.h: New. + + 2016-04-29 Oleg Endo + + * longlong.h (umul_ppmm): Remove SHMEDIA checks. + (__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations. + + 2017-09-15 Yao Qi + Pedro Alves + + * ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro. + + 2017-09-12 Jiong Wang + + * dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP. + * dwarf2.h (DW_CFA_DUP): New define. + + 2017-08-21 Richard Biener + + * simple-object.h (simple_object_copy_lto_debug_sections): New + function. + + 2017-05-18 Martin Liska + + * ansidecl.h: Define CONSTEXPR macro. + + 2017-05-24 Nathan Sidwell + + * libiberty.h (ASTRDUP): Adjust cast to avoid warning. + + 2017-01-30 Alexandre Oliva + + Introduce C++ support in libcc1. + * gcc-c-fe.def (int_type_v0): Rename from... + (int_type): ... this. Introduce new version. + (float_type_v0): Rename from... + (float_type): ... this. Introduce new version. + (char_type): New. + * gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1. + (gcc_type_array): Move... + * gcc-interface.h: ... here. + * gcc-cp-fe.def: New. + * gcc-cp-interface.h: New. + + 2016-04-29 Oleg Endo + + * longlong.h (umul_ppmm): Remove SHMEDIA checks. + (__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations. + 2017-09-06 Kamil Rytarowski * opcode/nds32.h: Rename __BIT() to N32_BIT(). diff --git a/include/ansidecl.h b/include/ansidecl.h index 0a74098466..450ce35da4 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -252,7 +252,7 @@ So instead we use the macro below and test it against specific values. */ # endif /* GNUC >= 3.0 */ #endif /* ATTRIBUTE_ALIGNED_ALIGNOF */ -/* Useful for structures whose layout must much some binary specification +/* Useful for structures whose layout must match some binary specification regardless of the alignment and padding qualities of the compiler. */ #ifndef ATTRIBUTE_PACKED # define ATTRIBUTE_PACKED __attribute__ ((packed)) @@ -313,6 +313,12 @@ So instead we use the macro below and test it against specific values. */ #define ENUM_BITFIELD(TYPE) unsigned int #endif +#if __cpp_constexpr >= 200704 +#define CONSTEXPR constexpr +#else +#define CONSTEXPR +#endif + /* C++11 adds the ability to add "override" after an implementation of a virtual function in a subclass, to: (A) document that this is an override of a virtual function @@ -354,6 +360,32 @@ So instead we use the macro below and test it against specific values. */ # define FINAL #endif +/* A macro to disable the copy constructor and assignment operator. + When building with C++11 and above, the methods are explicitly + deleted, causing a compile-time error if something tries to copy. + For C++03, this just declares the methods, causing a link-time + error if the methods end up called (assuming you don't + define them). For C++03, for best results, place the macro + under the private: access specifier, like this, + + class name_lookup + { + private: + DISABLE_COPY_AND_ASSIGN (name_lookup); + }; + + so that most attempts at copy are caught at compile-time. */ + +#if __cplusplus >= 201103 +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ + TYPE (const TYPE&) = delete; \ + void operator= (const TYPE &) = delete + #else +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ + TYPE (const TYPE&); \ + void operator= (const TYPE &) +#endif /* __cplusplus >= 201103 */ + #ifdef __cplusplus } #endif diff --git a/include/dwarf2.def b/include/dwarf2.def index a91e9439cd..2a3b23fef8 100644 --- a/include/dwarf2.def +++ b/include/dwarf2.def @@ -778,6 +778,7 @@ DW_CFA (DW_CFA_MIPS_advance_loc8, 0x1d) /* GNU extensions. NOTE: DW_CFA_GNU_window_save is multiplexed on Sparc and AArch64. */ DW_CFA (DW_CFA_GNU_window_save, 0x2d) +DW_CFA_DUP (DW_CFA_AARCH64_negate_ra_state, 0x2d) DW_CFA (DW_CFA_GNU_args_size, 0x2e) DW_CFA (DW_CFA_GNU_negative_offset_extended, 0x2f) diff --git a/include/dwarf2.h b/include/dwarf2.h index 14b6f22e39..a2e022dbdb 100644 --- a/include/dwarf2.h +++ b/include/dwarf2.h @@ -52,6 +52,7 @@ #define DW_ATE(name, value) , name = value #define DW_ATE_DUP(name, value) , name = value #define DW_CFA(name, value) , name = value +#define DW_CFA_DUP(name, value) , name = value #define DW_IDX(name, value) , name = value #define DW_IDX_DUP(name, value) , name = value @@ -104,6 +105,7 @@ #undef DW_ATE #undef DW_ATE_DUP #undef DW_CFA +#undef DW_CFA_DUP #undef DW_IDX #undef DW_IDX_DUP diff --git a/include/gcc-c-fe.def b/include/gcc-c-fe.def index 09998ba67e..acf1940c01 100644 --- a/include/gcc-c-fe.def +++ b/include/gcc-c-fe.def @@ -125,16 +125,18 @@ GCC_METHOD3 (gcc_type, build_function_type, const struct gcc_type_array *, /* Argument ARGUMENT_TYPES. */ int /* bool */) /* Argument IS_VARARGS. */ -/* Return an integer type with the given properties. */ +/* Return an integer type with the given properties. + Deprecated in v1, use int_type instead. */ -GCC_METHOD2 (gcc_type, int_type, +GCC_METHOD2 (gcc_type, int_type_v0, int /* bool */, /* Argument IS_UNSIGNED. */ unsigned long) /* Argument SIZE_IN_BYTES. */ -/* Return a floating point type with the given properties. */ +/* Return a floating point type with the given properties. + Deprecated in v1, use float_type instead. */ -GCC_METHOD1 (gcc_type, float_type, - unsigned long) /* Argument SIZE_IN_BYTES. */ +GCC_METHOD1 (gcc_type, float_type_v0, + unsigned long) /* Argument SIZE_IN_BYTES. */ /* Return the 'void' type. */ @@ -195,3 +197,26 @@ GCC_METHOD5 (int /* bool */, build_constant, GCC_METHOD1 (gcc_type, error, const char *) /* Argument MESSAGE. */ + +/* Return an integer type with the given properties. If BUILTIN_NAME + is non-NULL, it must name a builtin integral type with the given + signedness and size, and that is the type that will be returned. */ + +GCC_METHOD3 (gcc_type, int_type, + int /* bool */, /* Argument IS_UNSIGNED. */ + unsigned long, /* Argument SIZE_IN_BYTES. */ + const char *) /* Argument BUILTIN_NAME. */ + +/* Return the 'char' type, a distinct type from both 'signed char' and + 'unsigned char' returned by int_type. */ + +GCC_METHOD0 (gcc_type, char_type) + +/* Return a floating point type with the given properties. If BUILTIN_NAME + is non-NULL, it must name a builtin integral type with the given + signedness and size, and that is the type that will be returned. */ + +GCC_METHOD2 (gcc_type, float_type, + unsigned long, /* Argument SIZE_IN_BYTES. */ + const char *) /* Argument BUILTIN_NAME. */ + diff --git a/include/gcc-c-interface.h b/include/gcc-c-interface.h index 00ccbfb2a7..e048c86307 100644 --- a/include/gcc-c-interface.h +++ b/include/gcc-c-interface.h @@ -41,7 +41,11 @@ struct gcc_c_context; enum gcc_c_api_version { - GCC_C_FE_VERSION_0 = 0 + GCC_C_FE_VERSION_0 = 0, + + /* Added char_type. Added new version of int_type and float_type, + deprecated int_type_v0 and float_type_v0. */ + GCC_C_FE_VERSION_1 = 1 }; /* Qualifiers. */ @@ -111,19 +115,6 @@ typedef gcc_address gcc_c_symbol_address_function (void *datum, struct gcc_c_context *ctxt, const char *identifier); -/* An array of types used for creating a function type. */ - -struct gcc_type_array -{ - /* Number of elements. */ - - int n_elements; - - /* The elements. */ - - gcc_type *elements; -}; - /* The vtable used by the C front end. */ struct gcc_c_fe_vtable @@ -146,7 +137,7 @@ struct gcc_c_fe_vtable provides the declaration. DATUM is an arbitrary piece of data that is passed back verbatim - to the callbakcs in requests. */ + to the callbacks in requests. */ void (*set_callbacks) (struct gcc_c_context *self, gcc_c_oracle_function *binding_oracle, diff --git a/include/gcc-cp-fe.def b/include/gcc-cp-fe.def new file mode 100644 index 0000000000..c367c1db1e --- /dev/null +++ b/include/gcc-cp-fe.def @@ -0,0 +1,1050 @@ +/* Interface between GCC C++ FE and GDB -*- c -*- + + Copyright (C) 2014-2017 Free Software Foundation, Inc. + + This file is part of GCC. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + + +/* Push namespace NAME as the current binding level, to which + newly-introduced decls will be bound. An empty string identifies + the global namespace, whereas NULL identifies an anonymous + namespace. A namespace named NAME is created in the current scope, + if needed. + + If the newly-created namespace is to be an inline namespace, see + make_namespace_inline. */ + +GCC_METHOD1 (int /* bool */, push_namespace, + const char *) /* Argument NAME. */ + +/* Push TYPE as the current binding level, making its members visible + for name lookup. The current scope before the call must be the + scope in which the class was declared. This should be used if the + definition of a class is already finished, but one wishes to define + a nested class, or to enter the scope of one of its member + functions. */ + +GCC_METHOD1 (int /* bool */, push_class, + gcc_type) /* Argument TYPE. */ + +/* Push FUNCTION_DECL as the current (empty) binding level (see + reactivate_decl). The current enclosing scope before the call must + be the scope in which the function was declared. */ + +GCC_METHOD1 (int /* bool */, push_function, + gcc_decl) /* Argument FUNCTION_DECL. */ + +/* Make DECL visible (again?) within SCOPE. When SCOPE is NULL, it + means the current scope; if it is not NULL, it must name a function + that is currently active, even if not at the top of the binding + chain. + + This function can be used to make e.g. a global function or + variable visible in a namespace or local scope (overriding another + enclosing definition of the same name), but its most common + expected use of this primitive, that gives it its name, is to make + declarations visible again after reentering a function scope, + because when a function is entered with push_function, that does + NOT make any of the declarations nested in it visible for name + lookup. + + There is a reason/excuse for that: unlike namespaces and classes, + G++ doesn't ever have to reenter function scopes, so its name + resolution infrastructure is not prepared to do that. But wait, + there is also a good use for this apparent limitation: a function + may contain multiple scopes (blocks), and the name may be bound to + different symbols in each of these scopes. With this interface, as + we reenter a function scope, we may choose which symbols to make + visible for the code snippet, or, if there could be template + functions in local scopes, for unresolved names in nested template + class default arguments, or in nested template function signatures. + + As for making a local declaration visible for the code snippet, + there are two possibilities: a) introduce it upfront, while + entering the scope for the user expression (see the enter_scope + callback, called by g++ when encountering the push_user_expression + pragma), which might save some scope switching and reactivate_decl + (though this can't be helped if some declarations have to be + introduced and discarded, because of multiple definitions of the + same name in different scopes within a function: they have to be + defined in discriminator order); or b) introduce it when its name + is looked up, entering the scope, introducing the declaration, + leaving the scope, and then reactivating the declaration in its + local scope. + + Here's some more detail on how reactivate_decl works. Say there's + a function foo whose body looks like this: + + { + { +// point 1 + class c {} o __attribute__ ((__used__)); // c , o + } + struct c { + void f() { +// point 2 + } + } o __attribute__ ((__used__)); // c_0, o_0 + { + class c {} p __attribute__ ((__used__)); // c_1, p +// point 3 + o.f(); + } + } + + When we are about to define class c at point 1, we enter the + function foo scope, and since no symbols are visible at point 1, we + proceed to declare class c. We may then define the class right + away, or, if we leave the function scope, and we later wish to + define it, or to define object o, we can reenter the scope and just + use the previously-obtained gcc_decl to define the class, without + having to reactivate the declaration. + + Now, if we are to set up the binding context for point 2, we have + to define c_0::f, and in order to do so, we have to declare and + define c_0. Before we can declare c_0, we MUST at least declare c. + + As a general rule, before we can declare or define any local name + with a discriminator, we have to at least declare any other + occurrences of the same name in the same enclosing entity with + lower or absent discriminator. + + So, we declare c, then we leave the function scope and reenter it + so as to declare c_0 (also with name "c", which is why we have to + leave and reenter the function scope, otherwise we would get an + error because of the duplicate definition; g++ will assign a + discriminator because it still remembers there was an earlier + declaration of c_0 within the function, it's just no longer in + scope), then we can define c_0, including its member function f. + + Likewise, if we wish to define o_0, we have to define o first. If + we wish to declare (and maybe then define) c_1, we have to at least + declare (c and then) c_0 first. + + Then, as we set up the binding context to compile a code snippet at + point 3, we may choose to activate c_1, o_0 and p upfront, + declaring and discarding c, c_0 and o, and then reentering the + funciton scope to declare c_1, o_0 and p; or we can wait for oracle + lookups of c, o or p. If c is looked up, and the debugger resolves + c in the scope to c_1, it is expected to enter the function scope + from the top level, declare c, leave it, reenter it, declare c_0, + leave it, reenter it, declare c_1, leave it, and then reactivate + c_1 in the function scope. If c_1 is needed as a complete type, + the definition may be given right after the declaration, or the + scope will have to be reentered in order to define the class. + +. If the code snippet is at point 2, we don't need to (re)activate + any declaration: nothing from any local scope is visible. Just + entering the scope of the class containing member function f + reactivates the names of its members, including the class name + itself. */ + +GCC_METHOD2 (int /* bool */, reactivate_decl, + gcc_decl, /* Argument DECL. */ + gcc_decl) /* Argument SCOPE. */ + +/* Pop the namespace last entered with push_namespace, or class last + entered with push_class, or function last entered with + push_function, restoring the binding level in effect before the + matching push_* call. */ + +GCC_METHOD0 (int /* bool */, pop_binding_level) + +/* Return the NAMESPACE_DECL, TYPE_DECL or FUNCTION_DECL of the + binding level that would be popped by pop_scope. */ + +GCC_METHOD0 (gcc_decl, get_current_binding_level_decl) + +/* Make the current binding level an inline namespace. It must be a + namespace to begin with. It is safe to call this more than once + for the same namespace, but after the first call, subsequent ones + will not return a success status. */ + +GCC_METHOD0 (int /* bool */, make_namespace_inline) + +/* Add USED_NS to the namespaces used by the current binding level. + Use get_current_binding_level_decl to obtain USED_NS's + gcc_decl. */ + +GCC_METHOD1 (int /* bool */, add_using_namespace, + gcc_decl) /* Argument USED_NS. */ + +/* Introduce a namespace alias declaration, as in: + + namespace foo = [... ::] bar; + + After this call, namespace TARGET will be visible as ALIAS within + the current namespace. Get the declaration for TARGET by calling + get_current_binding_level_decl after pushing into it. */ + +GCC_METHOD2 (int /* bool */, add_namespace_alias, + const char *, /* Argument ALIAS. */ + gcc_decl) /* Argument TARGET. */ + +/* Introduce a using declaration, as in: + + using foo::bar; + + The TARGET decl names the qualifying scope (foo:: above) and the + identifier (bar), but that does not mean that only TARGET will be + brought into the current scope: all bindings of TARGET's identifier + in the qualifying scope will be brought in. + + FLAGS should specify GCC_CP_SYMBOL_USING. If the current scope is + a class scope, visibility flags must be supplied. + + Even when TARGET is template dependent, we don't need to specify + whether or not it is a typename: the supplied declaration (that + could be a template-dependent type converted to declaration by + get_type_decl) indicates so. */ + +GCC_METHOD2 (int /* bool */, add_using_decl, + enum gcc_cp_symbol_kind, /* Argument FLAGS. */ + gcc_decl) /* Argument TARGET. */ + +/* Create a new "decl" in GCC, and bind it in the current binding + level. A decl is a declaration, basically a kind of symbol. + + NAME is the name of the new symbol. SYM_KIND is the kind of + symbol being requested. SYM_TYPE is the new symbol's C++ type; + except for labels, where this is not meaningful and should be + zero. If SUBSTITUTION_NAME is not NULL, then a reference to this + decl in the source will later be substituted with a dereference + of a variable of the given name. Otherwise, for symbols having + an address (e.g., functions), ADDRESS is the address. FILENAME + and LINE_NUMBER refer to the symbol's source location. If this + is not known, FILENAME can be NULL and LINE_NUMBER can be 0. + This function returns the new decl. + + Use this function to register typedefs, functions and variables to + namespace and local binding levels, and typedefs, member functions + (static or not), and static data members to class binding levels. + Class members must have their access controls specified with + GCC_CP_ACCESS_* flags in SYM_KIND. + + Note that, since access controls are disabled, we have no means to + express private, protected and public. + + There are various flags that can be set in SYM_KIND to specify + additional semantics. Look for GCC_CP_FLAGs in the definition of + enum gcc_cp_symbol_kind in gcc-cp-interface.h. + + In order to define member functions, pass GCC_CP_SYMBOL_FUNCTION in + SYM_KIND, and a function_type for static member functions or a + method type for non-static member functions, including constructors + and destructors. Use build_function_type to create a function + type; for a method type, start by creating a function type without + any compiler-introduced artificial arguments (the implicit this + pointer, and the __in_chrg added to constructors and destructors, + and __vtt_parm added to the former), and then use build_method_type + to create the method type out of the class type and the function + type. + + For operator functions, set GCC_CP_FLAG_SPECIAL_FUNCTION in + SYM_KIND, in addition to any other applicable flags, and pass as + NAME a string starting with the two-character mangling for operator + name: "ps" for unary plus, "mL" for multiply and assign, *=; etc. + Use "cv" for type converstion operators (the target type portion + may be omitted, as it is taken from the return type in SYM_TYPE). + For operator"", use "li" followed by the identifier (the mangled + name mandates digits specifying the length of the identifier; if + present, they determine the end of the identifier, otherwise, the + identifier extents to the end of the string, so that "li3_Kme" and + "li_Km" are equivalent). + + Constructors and destructors need special care, because for each + constructor and destructor there may be multiple clones defined + internally by the compiler. With build_decl, you can introduce the + base declaration of a constructor or a destructor, setting + GCC_CP_FLAG_SPECIAL_FUNCTION the flag and using names starting with + capital "C" or "D", respectively, followed by a digit (see below), + a blank, or NUL ('\0'). DO NOT supply an ADDRESS or a + SUBSTITUTION_NAME to build_decl, it would be meaningless (and + rejected) for the base declaration; use define_cdtor_clone to + introduce the address of each clone. For constructor templates, + declare the template with build_decl, and then, for each + specialization, introduce it with + build_function_template_specialization, and then define the + addresses of each of its clones with define_cdtor_clone. + + NAMEs for GCC_CP_FLAG_SPECIAL_FUNCTION: + + NAME meaning + C? constructor base declaration (? may be 1, 2, 4, blank or NUL) + D? destructor base declaration (? may be 0, 1, 2, 4, blank or NUL) + nw operator new + na operator new[] + dl operator delete + da operator delete[] + ps operator + (unary) + ng operator - (unary) + ad operator & (unary) + de operator * (unary) + co operator ~ + pl operator + + mi operator - + ml operator * + dv operator / + rm operator % + an operator & + or operator | + eo operator ^ + aS operator = + pL operator += + mI operator -= + mL operator *= + dV operator /= + rM operator %= + aN operator &= + oR operator |= + eO operator ^= + ls operator << + rs operator >> + lS operator <<= + rS operator >>= + eq operator == + ne operator != + lt operator < + gt operator > + le operator <= + ge operator >= + nt operator ! + aa operator && + oo operator || + pp operator ++ + mm operator -- + cm operator , + pm operator ->* + pt operator -> + cl operator () + ix operator [] + qu operator ? + cv operator (conversion operator) + li operator "" + + FIXME: How about attributes? */ + +GCC_METHOD7 (gcc_decl, build_decl, + const char *, /* Argument NAME. */ + enum gcc_cp_symbol_kind, /* Argument SYM_KIND. */ + gcc_type, /* Argument SYM_TYPE. */ + const char *, /* Argument SUBSTITUTION_NAME. */ + gcc_address, /* Argument ADDRESS. */ + const char *, /* Argument FILENAME. */ + unsigned int) /* Argument LINE_NUMBER. */ + +/* Supply the ADDRESS of one of the multiple clones of constructor or + destructor CDTOR. The clone is specified by NAME, using the + following name mangling conventions: + + C1 in-charge constructor + C2 not-in-charge constructor + C4 unified constructor + D0 deleting destructor + D1 in-charge destructor + D2 not-in-charge destructor + D4 unified destructor + + The following information is not necessary to use the API. + + C1 initializes an instance of the class (rather than of derived + classes), including virtual base classes, whereas C2 initializes a + sub-object (of the given class type) of an instance of some derived + class (or a full object that doesn't have any virtual base + classes). + + D0 and D1 destruct an instance of the class, including virtual base + classes, but only the former calls operator delete to release the + object's storage at the end; D2 destructs a sub-object (of the + given class type) of an instance of a derived class (or a full + object that doesn't have any virtual base classes). + + The [CD]4 manglings (and symbol definitions) are non-standard, but + GCC uses them in some cases: rather than assuming they are + in-charge or not-in-charge, they test the implicit argument that + the others ignore to tell how to behave. These are used instead of + cloning when we just can't use aliases. */ + +GCC_METHOD3 (gcc_decl, define_cdtor_clone, + const char *, /* Argument NAME. */ + gcc_decl, /* Argument CDTOR. */ + gcc_address) /* Argument ADDRESS. */ + +/* Return the type associated with the given declaration. This is + most useful to obtain the type associated with a forward-declared + class, because it is the gcc_type, rather than the gcc_decl, that + has to be used to build other types, but build_decl returns a + gcc_decl rather than a gcc_type. This call can in theory be used + to obtain the type from any other declaration; it is supposed to + return the same type that was supplied when the declaration was + created. */ + +GCC_METHOD1 (gcc_type, get_decl_type, + gcc_decl) /* Argument DECL. */ + +/* Return the declaration for a type. */ + +GCC_METHOD1 (gcc_decl, get_type_decl, + gcc_type) /* Argument TYPE. */ + +/* Declare DECL as a friend of the current class scope, if TYPE is + NULL, or of TYPE itself otherwise. DECL may be a function or a + class, be they template generics, template specializations or not + templates. TYPE must be a class type (not a template generic). + + The add_friend call cannot introduce a declaration; even if the + friend is first declared as a friend in the source code, the + declaration belongs in the enclosing namespace, so it must be + introduced in that namespace, and the resulting declaration can + then be made a friend. + + DECL cannot, however, be a member of a template class generic, + because we have no means to introduce their declarations. This + interface has no notion of definitions for template generics. As a + consequence, users of this interface must introduce each friend + template member specialization separately, i.e., instead of: + + template friend struct X::M; + + they must be declared as if they were: + + friend struct X::M; + friend struct X::M; + ... for each specialization of X. + + + Specializations of a template can have each others' members as + friends: + + template class foo { + int f(); + template friend int foo::f(); + }; + + It wouldn't always be possible to define all specializations of a + template class before introducing the friend declarations in their + expanded, per-specialization form. + + In order to simplify such friend declarations, and to enable + incremental friend declarations as template specializations are + introduced, add_friend can be called after the befriending class is + fully defined, passing it a non-NULL TYPE argument naming the + befriending class type. */ + +GCC_METHOD2 (int /* bool */, add_friend, + gcc_decl, /* Argument DECL. */ + gcc_type) /* Argument TYPE. */ + +/* Return the type of a pointer to a given base type. */ + +GCC_METHOD1 (gcc_type, build_pointer_type, + gcc_type) /* Argument BASE_TYPE. */ + +/* Return the type of a reference to a given base type. */ + +GCC_METHOD2 (gcc_type, build_reference_type, + gcc_type, /* Argument BASE_TYPE. */ + enum gcc_cp_ref_qualifiers) /* Argument RQUALS. */ + +/* Create a new pointer-to-member type. MEMBER_TYPE is the data + member type, while CLASS_TYPE is the class type containing the data + member. For pointers to member functions, MEMBER_TYPE must be a + method type, and CLASS_TYPE must be specified even though it might + be possible to extract it from the method type. */ + +GCC_METHOD2 (gcc_type, build_pointer_to_member_type, + gcc_type, /* Argument CLASS_TYPE. */ + gcc_type) /* Argument MEMBER_TYPE. */ + +/* Start a template parameter list scope and enters it, so that + subsequent build_type_template_parameter and + build_value_template_parameter calls create template parameters in + the list. The list is closed by a build_decl call with + GCC_CP_SYMBOL_FUNCTION or GCC_CP_SYMBOL_CLASS, that, when the scope + is a template parameter list, declares a template function or a + template class with the then-closed parameter list. The scope in + which the new declaration is to be introduced by build_decl must be + entered before calling start_template_decl, and build_decl returns + to that scope, from the template parameter list scope, before + introducing the declaration. */ + +GCC_METHOD0 (int /* bool */, start_template_decl) + +/* Build a typename template-parameter (e.g., the T in template + ). Either PACK_P should be nonzero, to indicate an + argument pack (the last argument in a variadic template argument + list, as in template ), or DEFAULT_TYPE may be + non-NULL to set the default type argument (e.g. X) for the template + parameter. FILENAME and LINE_NUMBER may specify the source + location in which the template parameter was declared. */ + +GCC_METHOD5 (gcc_type, build_type_template_parameter, + const char *, /* Argument ID. */ + int /* bool */, /* Argument PACK_P. */ + gcc_type, /* Argument DEFAULT_TYPE. */ + const char *, /* Argument FILENAME. */ + unsigned int) /* Argument LINE_NUMBER. */ + +/* Build a template template-parameter (e.g., the T in template +