xref: /netbsd-src/external/gpl3/gcc.old/dist/include/gcc-cp-interface.h (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
13ad841b2Smrg /* Interface between GCC C++ FE and GDB
23ad841b2Smrg 
3*4c3eb207Smrg    Copyright (C) 2014-2020 Free Software Foundation, Inc.
43ad841b2Smrg 
53ad841b2Smrg    This file is part of GCC.
63ad841b2Smrg 
73ad841b2Smrg    This program is free software; you can redistribute it and/or modify
83ad841b2Smrg    it under the terms of the GNU General Public License as published by
93ad841b2Smrg    the Free Software Foundation; either version 3 of the License, or
103ad841b2Smrg    (at your option) any later version.
113ad841b2Smrg 
123ad841b2Smrg    This program is distributed in the hope that it will be useful,
133ad841b2Smrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
143ad841b2Smrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
153ad841b2Smrg    GNU General Public License for more details.
163ad841b2Smrg 
173ad841b2Smrg    You should have received a copy of the GNU General Public License
183ad841b2Smrg    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
193ad841b2Smrg 
203ad841b2Smrg #ifndef GCC_CP_INTERFACE_H
213ad841b2Smrg #define GCC_CP_INTERFACE_H
223ad841b2Smrg 
233ad841b2Smrg #include "gcc-interface.h"
243ad841b2Smrg 
253ad841b2Smrg /* This header defines the interface to the GCC API.  It must be both
263ad841b2Smrg    valid C and valid C++, because it is included by both programs.  */
273ad841b2Smrg 
283ad841b2Smrg #ifdef __cplusplus
293ad841b2Smrg extern "C" {
303ad841b2Smrg #endif
313ad841b2Smrg 
323ad841b2Smrg /* Forward declaration.  */
333ad841b2Smrg 
343ad841b2Smrg struct gcc_cp_context;
353ad841b2Smrg 
363ad841b2Smrg /*
373ad841b2Smrg  * Definitions and declarations for the C++ front end.
383ad841b2Smrg  */
393ad841b2Smrg 
403ad841b2Smrg /* Defined versions of the C++ front-end API.  */
413ad841b2Smrg 
423ad841b2Smrg enum gcc_cp_api_version
433ad841b2Smrg {
443ad841b2Smrg   GCC_CP_FE_VERSION_0 = 0
453ad841b2Smrg };
463ad841b2Smrg 
473ad841b2Smrg /* Qualifiers.  */
483ad841b2Smrg 
493ad841b2Smrg enum gcc_cp_qualifiers
503ad841b2Smrg {
513ad841b2Smrg   GCC_CP_QUALIFIER_CONST = 1,
523ad841b2Smrg   GCC_CP_QUALIFIER_VOLATILE = 2,
533ad841b2Smrg   GCC_CP_QUALIFIER_RESTRICT = 4
543ad841b2Smrg };
553ad841b2Smrg 
563ad841b2Smrg /* Ref qualifiers.  */
573ad841b2Smrg 
583ad841b2Smrg enum gcc_cp_ref_qualifiers {
593ad841b2Smrg   GCC_CP_REF_QUAL_NONE = 0,
603ad841b2Smrg   GCC_CP_REF_QUAL_LVALUE = 1,
613ad841b2Smrg   GCC_CP_REF_QUAL_RVALUE = 2
623ad841b2Smrg };
633ad841b2Smrg 
643ad841b2Smrg /* Opaque typedef for unbound class templates.  They are used for
653ad841b2Smrg    template arguments, and defaults for template template
663ad841b2Smrg    parameters.  */
673ad841b2Smrg 
683ad841b2Smrg typedef unsigned long long gcc_utempl;
693ad841b2Smrg 
703ad841b2Smrg /* Opaque typedef for expressions.  They are used for template
713ad841b2Smrg    arguments, defaults for non-type template parameters, and defaults
723ad841b2Smrg    for function arguments.  */
733ad841b2Smrg 
743ad841b2Smrg typedef unsigned long long gcc_expr;
753ad841b2Smrg 
763ad841b2Smrg typedef enum
773ad841b2Smrg   { GCC_CP_TPARG_VALUE, GCC_CP_TPARG_CLASS,
783ad841b2Smrg     GCC_CP_TPARG_TEMPL, GCC_CP_TPARG_PACK }
793ad841b2Smrg gcc_cp_template_arg_kind;
803ad841b2Smrg 
813ad841b2Smrg typedef union
823ad841b2Smrg { gcc_expr value; gcc_type type; gcc_utempl templ; gcc_type pack; }
833ad841b2Smrg gcc_cp_template_arg;
843ad841b2Smrg 
853ad841b2Smrg /* An array of template arguments.  */
863ad841b2Smrg 
873ad841b2Smrg struct gcc_cp_template_args
883ad841b2Smrg {
893ad841b2Smrg   /* Number of elements.  */
903ad841b2Smrg 
913ad841b2Smrg   int n_elements;
923ad841b2Smrg 
933ad841b2Smrg   /* kind[i] indicates what kind of template argument type[i] is.  */
943ad841b2Smrg 
953ad841b2Smrg   char /* gcc_cp_template_arg_kind */ *kinds;
963ad841b2Smrg 
973ad841b2Smrg   /* The template arguments.  */
983ad841b2Smrg 
993ad841b2Smrg   gcc_cp_template_arg *elements;
1003ad841b2Smrg };
1013ad841b2Smrg 
1023ad841b2Smrg /* An array of (default) function arguments.  */
1033ad841b2Smrg 
1043ad841b2Smrg struct gcc_cp_function_args
1053ad841b2Smrg {
1063ad841b2Smrg   /* Number of elements.  */
1073ad841b2Smrg 
1083ad841b2Smrg   int n_elements;
1093ad841b2Smrg 
1103ad841b2Smrg   /* The (default) values for each argument.  */
1113ad841b2Smrg 
1123ad841b2Smrg   gcc_expr *elements;
1133ad841b2Smrg };
1143ad841b2Smrg 
1153ad841b2Smrg /* This enumerates the kinds of decls that GDB can create.  */
1163ad841b2Smrg 
1173ad841b2Smrg enum gcc_cp_symbol_kind
1183ad841b2Smrg {
1193ad841b2Smrg   /* A function.  */
1203ad841b2Smrg 
1213ad841b2Smrg   GCC_CP_SYMBOL_FUNCTION,
1223ad841b2Smrg 
1233ad841b2Smrg   /* A variable.  */
1243ad841b2Smrg 
1253ad841b2Smrg   GCC_CP_SYMBOL_VARIABLE,
1263ad841b2Smrg 
1273ad841b2Smrg   /* A typedef, or an alias declaration (including template ones).  */
1283ad841b2Smrg 
1293ad841b2Smrg   GCC_CP_SYMBOL_TYPEDEF,
1303ad841b2Smrg 
1313ad841b2Smrg   /* A label.  */
1323ad841b2Smrg 
1333ad841b2Smrg   GCC_CP_SYMBOL_LABEL,
1343ad841b2Smrg 
1353ad841b2Smrg   /* A class, forward declared in build_decl (to be later defined in
1363ad841b2Smrg      start_class_definition), or, in a template parameter list scope,
1373ad841b2Smrg      a declaration of a template class, closing the parameter
1383ad841b2Smrg      list.  */
1393ad841b2Smrg 
1403ad841b2Smrg   GCC_CP_SYMBOL_CLASS,
1413ad841b2Smrg 
1423ad841b2Smrg   /* A union, forward declared in build_decl (to be later defined in
1433ad841b2Smrg      start_class_definition).  */
1443ad841b2Smrg 
1453ad841b2Smrg   GCC_CP_SYMBOL_UNION,
1463ad841b2Smrg 
1473ad841b2Smrg   /* An enumeration type being introduced with start_new_enum_type.  */
1483ad841b2Smrg 
1493ad841b2Smrg   GCC_CP_SYMBOL_ENUM,
1503ad841b2Smrg 
1513ad841b2Smrg   /* A nonstatic data member being introduced with new_field.  */
1523ad841b2Smrg 
1533ad841b2Smrg   GCC_CP_SYMBOL_FIELD,
1543ad841b2Smrg 
1553ad841b2Smrg   /* A base class in a gcc_vbase_array.  */
1563ad841b2Smrg 
1573ad841b2Smrg   GCC_CP_SYMBOL_BASECLASS,
1583ad841b2Smrg 
1593ad841b2Smrg   /* A using declaration in new_using_decl.  */
1603ad841b2Smrg 
1613ad841b2Smrg   GCC_CP_SYMBOL_USING,
1623ad841b2Smrg 
1633ad841b2Smrg   /* A (lambda) closure class type.  In many regards this is just like
1643ad841b2Smrg      a regular class, but it's not supposed to have base classes, some
1653ad841b2Smrg      of the member functions that are usually implicitly-defined are
1663ad841b2Smrg      deleted, and it should have an operator() member function that
1673ad841b2Smrg      holds the lambda body.  We can't instantiate objects of lambda
1683ad841b2Smrg      types from the snippet, but we can interact with them in such
1693ad841b2Smrg      ways as passing them to functions that take their types, and
1703ad841b2Smrg      calling their body.  */
1713ad841b2Smrg 
1723ad841b2Smrg   GCC_CP_SYMBOL_LAMBDA_CLOSURE,
1733ad841b2Smrg 
1743ad841b2Smrg   /* Marker to check that we haven't exceeded GCC_CP_SYMBOL_MASK.  */
1753ad841b2Smrg   GCC_CP_SYMBOL_END,
1763ad841b2Smrg 
1773ad841b2Smrg   GCC_CP_SYMBOL_MASK = 15,
1783ad841b2Smrg 
1793ad841b2Smrg   /* When defining a class member, at least one of the
1803ad841b2Smrg      GCC_CP_ACCESS_MASK bits must be set; when defining a namespace-
1813ad841b2Smrg      or union-scoped symbol, none of them must be set.  */
1823ad841b2Smrg 
1833ad841b2Smrg   GCC_CP_ACCESS_PRIVATE,
1843ad841b2Smrg   GCC_CP_ACCESS_PUBLIC = GCC_CP_ACCESS_PRIVATE << 1,
1853ad841b2Smrg   GCC_CP_ACCESS_MASK = (GCC_CP_ACCESS_PUBLIC
1863ad841b2Smrg 			       | GCC_CP_ACCESS_PRIVATE),
1873ad841b2Smrg   GCC_CP_ACCESS_PROTECTED = GCC_CP_ACCESS_MASK,
1883ad841b2Smrg   GCC_CP_ACCESS_NONE = 0,
1893ad841b2Smrg 
1903ad841b2Smrg   GCC_CP_FLAG_BASE = GCC_CP_ACCESS_PRIVATE << 2,
1913ad841b2Smrg 
1923ad841b2Smrg   /* Flags to be used along with GCC_CP_SYMBOL_FUNCTION:  */
1933ad841b2Smrg 
1943ad841b2Smrg   /* This flag should be set for constructors, destructors and
1953ad841b2Smrg      operators.  */
1963ad841b2Smrg   GCC_CP_FLAG_SPECIAL_FUNCTION = GCC_CP_FLAG_BASE,
1973ad841b2Smrg 
1983ad841b2Smrg   /* We intentionally cannot express inline, constexpr, or virtual
1993ad841b2Smrg      override for functions.  We can't inline or constexpr-replace
2003ad841b2Smrg      without a source-level body.  The override keyword is only
2013ad841b2Smrg      meaningful within the definition of the containing class.  */
2023ad841b2Smrg 
2033ad841b2Smrg   /* This indicates a "virtual" member function, explicitly or
2043ad841b2Smrg      implicitly (due to a virtual function with the same name and
2053ad841b2Smrg      prototype in a base class) declared as such.  */
2063ad841b2Smrg   GCC_CP_FLAG_VIRTUAL_FUNCTION = GCC_CP_FLAG_BASE << 1,
2073ad841b2Smrg 
2083ad841b2Smrg   /* The following two flags should only be set when the flag above is
2093ad841b2Smrg      set.  */
2103ad841b2Smrg 
2113ad841b2Smrg   /* This indicates a pure virtual member function, i.e., one that is
2123ad841b2Smrg      declared with "= 0", even if a body is provided in the
2133ad841b2Smrg      definition.  */
2143ad841b2Smrg   GCC_CP_FLAG_PURE_VIRTUAL_FUNCTION = GCC_CP_FLAG_BASE << 2,
2153ad841b2Smrg 
2163ad841b2Smrg   /* This indicates a "final" virtual member function.  */
2173ad841b2Smrg   GCC_CP_FLAG_FINAL_VIRTUAL_FUNCTION = GCC_CP_FLAG_BASE << 3,
2183ad841b2Smrg 
2193ad841b2Smrg   /* This indicates a special member function should have its default
2203ad841b2Smrg      implementation.  This either means the function declaration
2213ad841b2Smrg      contains the "= default" tokens, or that the member function was
2223ad841b2Smrg      implicitly generated by the compiler, although the latter use is
2233ad841b2Smrg      discouraged: just let the compiler implicitly introduce it.
2243ad841b2Smrg 
2253ad841b2Smrg      A member function defaulted after its first declaration has
2263ad841b2Smrg      slightly different ABI implications from one implicitly generated
2273ad841b2Smrg      or explicitly defaulted at the declaration (and definition)
2283ad841b2Smrg      point.  To avoid silent (possibly harmless) violation of the one
2293ad841b2Smrg      definition rule, it is recommended that this flag not be used for
2303ad841b2Smrg      such functions, and that the address of the definition be
2313ad841b2Smrg      supplied instead.  */
2323ad841b2Smrg   GCC_CP_FLAG_DEFAULTED_FUNCTION = GCC_CP_FLAG_BASE << 4,
2333ad841b2Smrg 
2343ad841b2Smrg   /* This indicates a deleted member function, i.e., one that has been
2353ad841b2Smrg      defined as "= delete" at its declaration point, or one that has
2363ad841b2Smrg      been implicitly defined as deleted (with or without an explicit
2373ad841b2Smrg      "= default" definition).
2383ad841b2Smrg 
2393ad841b2Smrg      This should not be used for implicitly-declared member functions
2403ad841b2Smrg      that resolve to deleted definitions, as it may affect the
2413ad841b2Smrg      implicit declaration of other member functions.  */
2423ad841b2Smrg   GCC_CP_FLAG_DELETED_FUNCTION = GCC_CP_FLAG_BASE << 5,
2433ad841b2Smrg 
2443ad841b2Smrg   /* This indicates a constructor or type-conversion operator declared
2453ad841b2Smrg      as "explicit".  */
2463ad841b2Smrg 
2473ad841b2Smrg   GCC_CP_FLAG_EXPLICIT_FUNCTION = GCC_CP_FLAG_BASE << 6,
2483ad841b2Smrg 
2493ad841b2Smrg   GCC_CP_FLAG_END_FUNCTION,
2503ad841b2Smrg   GCC_CP_FLAG_MASK_FUNCTION = (((GCC_CP_FLAG_END_FUNCTION - 1) << 1)
2513ad841b2Smrg 			       - GCC_CP_FLAG_BASE),
2523ad841b2Smrg 
2533ad841b2Smrg   /* Flags to be used along with GCC_CP_SYMBOL_VARIABLE:  */
2543ad841b2Smrg 
2553ad841b2Smrg   /* This indicates a variable declared as "constexpr".  */
2563ad841b2Smrg 
2573ad841b2Smrg   GCC_CP_FLAG_CONSTEXPR_VARIABLE = GCC_CP_FLAG_BASE,
2583ad841b2Smrg 
2593ad841b2Smrg   /* This indicates a variable declared as "thread_local".  ??? What
2603ad841b2Smrg      should the ADDRESS be?  */
2613ad841b2Smrg 
2623ad841b2Smrg   GCC_CP_FLAG_THREAD_LOCAL_VARIABLE = GCC_CP_FLAG_BASE << 1,
2633ad841b2Smrg 
2643ad841b2Smrg   GCC_CP_FLAG_END_VARIABLE,
2653ad841b2Smrg   GCC_CP_FLAG_MASK_VARIABLE = (((GCC_CP_FLAG_END_VARIABLE - 1) << 1)
2663ad841b2Smrg 			       - GCC_CP_FLAG_BASE),
2673ad841b2Smrg 
2683ad841b2Smrg   /* Flags to be used when defining nonstatic data members of classes
2693ad841b2Smrg      with new_field.  */
2703ad841b2Smrg 
2713ad841b2Smrg   /* Use this when no flags are present.  */
2723ad841b2Smrg   GCC_CP_FLAG_FIELD_NOFLAG = 0,
2733ad841b2Smrg 
2743ad841b2Smrg   /* This indicates the field is declared as mutable.  */
2753ad841b2Smrg   GCC_CP_FLAG_FIELD_MUTABLE = GCC_CP_FLAG_BASE,
2763ad841b2Smrg 
2773ad841b2Smrg   GCC_CP_FLAG_END_FIELD,
2783ad841b2Smrg   GCC_CP_FLAG_MASK_FIELD = (((GCC_CP_FLAG_END_FIELD - 1) << 1)
2793ad841b2Smrg 			    - GCC_CP_FLAG_BASE),
2803ad841b2Smrg 
2813ad841b2Smrg   /* Flags to be used when defining an enum with
2823ad841b2Smrg      start_new_enum_type.  */
2833ad841b2Smrg 
2843ad841b2Smrg   /* This indicates an enum type without any flags.  */
2853ad841b2Smrg   GCC_CP_FLAG_ENUM_NOFLAG = 0,
2863ad841b2Smrg 
2873ad841b2Smrg   /* This indicates a scoped enum type.  */
2883ad841b2Smrg   GCC_CP_FLAG_ENUM_SCOPED = GCC_CP_FLAG_BASE,
2893ad841b2Smrg 
2903ad841b2Smrg   GCC_CP_FLAG_END_ENUM,
2913ad841b2Smrg   GCC_CP_FLAG_MASK_ENUM = (((GCC_CP_FLAG_END_ENUM - 1) << 1)
2923ad841b2Smrg 			       - GCC_CP_FLAG_BASE),
2933ad841b2Smrg 
2943ad841b2Smrg 
2953ad841b2Smrg   /* Flags to be used when introducing a class or a class template
2963ad841b2Smrg      with build_decl.  */
2973ad841b2Smrg 
2983ad841b2Smrg   /* This indicates an enum type without any flags.  */
2993ad841b2Smrg   GCC_CP_FLAG_CLASS_NOFLAG = 0,
3003ad841b2Smrg 
3013ad841b2Smrg   /* This indicates the class is actually a struct.  This has no
3023ad841b2Smrg      effect whatsoever on access control in this interface, since all
3033ad841b2Smrg      class members must have explicit access control bits set, but it
3043ad841b2Smrg      may affect error messages.  */
3053ad841b2Smrg   GCC_CP_FLAG_CLASS_IS_STRUCT = GCC_CP_FLAG_BASE,
3063ad841b2Smrg 
3073ad841b2Smrg   GCC_CP_FLAG_END_CLASS,
3083ad841b2Smrg   GCC_CP_FLAG_MASK_CLASS = (((GCC_CP_FLAG_END_CLASS - 1) << 1)
3093ad841b2Smrg 			       - GCC_CP_FLAG_BASE),
3103ad841b2Smrg 
3113ad841b2Smrg 
3123ad841b2Smrg   /* Flags to be used when introducing a virtual base class in a
3133ad841b2Smrg      gcc_vbase_array.  */
3143ad841b2Smrg 
3153ad841b2Smrg   /* This indicates an enum type without any flags.  */
3163ad841b2Smrg   GCC_CP_FLAG_BASECLASS_NOFLAG = 0,
3173ad841b2Smrg 
3183ad841b2Smrg   /* This indicates the class is actually a struct.  This has no
3193ad841b2Smrg      effect whatsoever on access control in this interface, since all
3203ad841b2Smrg      class members must have explicit access control bits set, but it
3213ad841b2Smrg      may affect error messages.  */
3223ad841b2Smrg   GCC_CP_FLAG_BASECLASS_VIRTUAL = GCC_CP_FLAG_BASE,
3233ad841b2Smrg 
3243ad841b2Smrg   GCC_CP_FLAG_END_BASECLASS,
3253ad841b2Smrg   GCC_CP_FLAG_MASK_BASECLASS = (((GCC_CP_FLAG_END_BASECLASS - 1) << 1)
3263ad841b2Smrg 				- GCC_CP_FLAG_BASE),
3273ad841b2Smrg 
3283ad841b2Smrg 
3293ad841b2Smrg   GCC_CP_FLAG_MASK = (GCC_CP_FLAG_MASK_FUNCTION
3303ad841b2Smrg 		      | GCC_CP_FLAG_MASK_VARIABLE
3313ad841b2Smrg 		      | GCC_CP_FLAG_MASK_FIELD
3323ad841b2Smrg 		      | GCC_CP_FLAG_MASK_ENUM
3333ad841b2Smrg 		      | GCC_CP_FLAG_MASK_CLASS
3343ad841b2Smrg 		      | GCC_CP_FLAG_MASK_BASECLASS
3353ad841b2Smrg 		      )
3363ad841b2Smrg };
3373ad841b2Smrg 
3383ad841b2Smrg 
3393ad841b2Smrg /* An array of types used for creating lists of base classes.  */
3403ad841b2Smrg 
3413ad841b2Smrg struct gcc_vbase_array
3423ad841b2Smrg {
3433ad841b2Smrg   /* Number of elements.  */
3443ad841b2Smrg 
3453ad841b2Smrg   int n_elements;
3463ad841b2Smrg 
3473ad841b2Smrg   /* The base classes.  */
3483ad841b2Smrg 
3493ad841b2Smrg   gcc_type *elements;
3503ad841b2Smrg 
3513ad841b2Smrg   /* Flags for each base class.  Used to indicate access control and
3523ad841b2Smrg      virtualness.  */
3533ad841b2Smrg 
3543ad841b2Smrg   enum gcc_cp_symbol_kind *flags;
3553ad841b2Smrg };
3563ad841b2Smrg 
3573ad841b2Smrg 
3583ad841b2Smrg /* This enumerates the types of symbols that GCC might request from
3593ad841b2Smrg    GDB.  */
3603ad841b2Smrg 
3613ad841b2Smrg enum gcc_cp_oracle_request
3623ad841b2Smrg {
3633ad841b2Smrg   /* An identifier in namespace scope -- type, variable, function,
3643ad841b2Smrg      namespace, template.  All namespace-scoped symbols with the
3653ad841b2Smrg      requested name, in any namespace (including the global
3663ad841b2Smrg      namespace), should be defined in response to this request.  */
3673ad841b2Smrg 
3683ad841b2Smrg   GCC_CP_ORACLE_IDENTIFIER
3693ad841b2Smrg };
3703ad841b2Smrg 
3713ad841b2Smrg /* The type of the function called by GCC to ask GDB for a symbol's
3723ad841b2Smrg    definition.  DATUM is an arbitrary value supplied when the oracle
3733ad841b2Smrg    function is registered.  CONTEXT is the GCC context in which the
3743ad841b2Smrg    request is being made.  REQUEST specifies what sort of symbol is
3753ad841b2Smrg    being requested, and IDENTIFIER is the name of the symbol.  */
3763ad841b2Smrg 
3773ad841b2Smrg typedef void gcc_cp_oracle_function (void *datum,
3783ad841b2Smrg 				     struct gcc_cp_context *context,
3793ad841b2Smrg 				     enum gcc_cp_oracle_request request,
3803ad841b2Smrg 				     const char *identifier);
3813ad841b2Smrg 
3823ad841b2Smrg /* The type of the function called by GCC to ask GDB for a symbol's
3833ad841b2Smrg    address.  This should return 0 if the address is not known.  */
3843ad841b2Smrg 
3853ad841b2Smrg typedef gcc_address gcc_cp_symbol_address_function (void *datum,
3863ad841b2Smrg 						    struct gcc_cp_context *ctxt,
3873ad841b2Smrg 						    const char *identifier);
3883ad841b2Smrg 
3893ad841b2Smrg /* The type of the function called by GCC to ask GDB to enter or leave
3903ad841b2Smrg    the user expression scope.  */
3913ad841b2Smrg 
3923ad841b2Smrg typedef void gcc_cp_enter_leave_user_expr_scope_function (void *datum,
3933ad841b2Smrg 							  struct gcc_cp_context
3943ad841b2Smrg 							  *context);
3953ad841b2Smrg 
3963ad841b2Smrg /* The vtable used by the C front end.  */
3973ad841b2Smrg 
3983ad841b2Smrg struct gcc_cp_fe_vtable
3993ad841b2Smrg {
4003ad841b2Smrg   /* The version of the C interface.  The value is one of the
4013ad841b2Smrg      gcc_cp_api_version constants.  */
4023ad841b2Smrg 
4033ad841b2Smrg   unsigned int cp_version;
4043ad841b2Smrg 
4053ad841b2Smrg   /* Set the callbacks for this context.
4063ad841b2Smrg 
4073ad841b2Smrg      The binding oracle is called whenever the C++ parser needs to
4083ad841b2Smrg      look up a symbol.  This gives the caller a chance to lazily
4093ad841b2Smrg      instantiate symbols using other parts of the gcc_cp_fe_interface
4103ad841b2Smrg      API.  The symbol is looked up without a scope, and the oracle
4113ad841b2Smrg      must supply a definition for ALL namespace-scoped definitions
4123ad841b2Smrg      bound to the symbol.
4133ad841b2Smrg 
4143ad841b2Smrg      The address oracle is called whenever the C++ parser needs to
4153ad841b2Smrg      look up a symbol.  This may be called for symbols not provided by
4163ad841b2Smrg      the symbol oracle, such as built-in functions where GCC provides
4173ad841b2Smrg      the declaration; other internal symbols, such as those related
4183ad841b2Smrg      with thunks, rtti, and virtual tables are likely to be queried
4193ad841b2Smrg      through this interface too.  The identifier is a mangled symbol
4203ad841b2Smrg      name.
4213ad841b2Smrg 
4223ad841b2Smrg      DATUM is an arbitrary piece of data that is passed back verbatim
4233ad841b2Smrg      to the callbacks in requests.  */
4243ad841b2Smrg 
4253ad841b2Smrg   void (*set_callbacks) (struct gcc_cp_context *self,
4263ad841b2Smrg 			 gcc_cp_oracle_function *binding_oracle,
4273ad841b2Smrg 			 gcc_cp_symbol_address_function *address_oracle,
4283ad841b2Smrg 			 gcc_cp_enter_leave_user_expr_scope_function *enter_scope,
4293ad841b2Smrg 			 gcc_cp_enter_leave_user_expr_scope_function *leave_scope,
4303ad841b2Smrg 			 void *datum);
4313ad841b2Smrg 
4323ad841b2Smrg #define GCC_METHOD0(R, N) \
4333ad841b2Smrg   R (*N) (struct gcc_cp_context *);
4343ad841b2Smrg #define GCC_METHOD1(R, N, A) \
4353ad841b2Smrg   R (*N) (struct gcc_cp_context *, A);
4363ad841b2Smrg #define GCC_METHOD2(R, N, A, B) \
4373ad841b2Smrg   R (*N) (struct gcc_cp_context *, A, B);
4383ad841b2Smrg #define GCC_METHOD3(R, N, A, B, C) \
4393ad841b2Smrg   R (*N) (struct gcc_cp_context *, A, B, C);
4403ad841b2Smrg #define GCC_METHOD4(R, N, A, B, C, D) \
4413ad841b2Smrg   R (*N) (struct gcc_cp_context *, A, B, C, D);
4423ad841b2Smrg #define GCC_METHOD5(R, N, A, B, C, D, E) \
4433ad841b2Smrg   R (*N) (struct gcc_cp_context *, A, B, C, D, E);
4443ad841b2Smrg #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
4453ad841b2Smrg   R (*N) (struct gcc_cp_context *, A, B, C, D, E, F, G);
4463ad841b2Smrg 
4473ad841b2Smrg #include "gcc-cp-fe.def"
4483ad841b2Smrg 
4493ad841b2Smrg #undef GCC_METHOD0
4503ad841b2Smrg #undef GCC_METHOD1
4513ad841b2Smrg #undef GCC_METHOD2
4523ad841b2Smrg #undef GCC_METHOD3
4533ad841b2Smrg #undef GCC_METHOD4
4543ad841b2Smrg #undef GCC_METHOD5
4553ad841b2Smrg #undef GCC_METHOD7
4563ad841b2Smrg 
4573ad841b2Smrg };
4583ad841b2Smrg 
4593ad841b2Smrg /* The C front end object.  */
4603ad841b2Smrg 
4613ad841b2Smrg struct gcc_cp_context
4623ad841b2Smrg {
4633ad841b2Smrg   /* Base class.  */
4643ad841b2Smrg 
4653ad841b2Smrg   struct gcc_base_context base;
4663ad841b2Smrg 
4673ad841b2Smrg   /* Our vtable.  This is a separate field because this is simpler
4683ad841b2Smrg      than implementing a vtable inheritance scheme in C.  */
4693ad841b2Smrg 
4703ad841b2Smrg   const struct gcc_cp_fe_vtable *cp_ops;
4713ad841b2Smrg };
4723ad841b2Smrg 
4733ad841b2Smrg /* The name of the .so that the compiler builds.  We dlopen this
4743ad841b2Smrg    later.  */
4753ad841b2Smrg 
4763ad841b2Smrg #define GCC_CP_FE_LIBCC libcc1.so
4773ad841b2Smrg 
4783ad841b2Smrg /* The compiler exports a single initialization function.  This macro
4793ad841b2Smrg    holds its name as a symbol.  */
4803ad841b2Smrg 
4813ad841b2Smrg #define GCC_CP_FE_CONTEXT gcc_cp_fe_context
4823ad841b2Smrg 
4833ad841b2Smrg /* The type of the initialization function.  The caller passes in the
4843ad841b2Smrg    desired base version and desired C-specific version.  If the
4853ad841b2Smrg    request can be satisfied, a compatible gcc_context object will be
4863ad841b2Smrg    returned.  Otherwise, the function returns NULL.  */
4873ad841b2Smrg 
4883ad841b2Smrg typedef struct gcc_cp_context *gcc_cp_fe_context_function
4893ad841b2Smrg     (enum gcc_base_api_version,
4903ad841b2Smrg      enum gcc_cp_api_version);
4913ad841b2Smrg 
4923ad841b2Smrg #ifdef __cplusplus
4933ad841b2Smrg }
4943ad841b2Smrg #endif
4953ad841b2Smrg 
4963ad841b2Smrg #endif /* GCC_CP_INTERFACE_H */
497