cp-tree.def (NEW_EXPR): Add a fourth slot.

* cp-tree.def (NEW_EXPR): Add a fourth slot.
	* cp-tree.h (PARMLIST_ELLIPSIS_P): Remove.
	(TREE_PARMLIST): Likewise.
	(CALL_DECLARATOR_PARMS): Likewise.
	(CALL_DECLARATOR_QUALS): Likewise.
	(CALL_DECLARATOR_EXCEPTION_SPEC): Likewise.
	(cp_declarator_kind): New type.
	(cp_parameter_declarator): Likewise.
	(cp_declarator): Likewise.
	(cp_error_declarator): Likewise.
	(no_parameters): Likewise.
	(groktypename): Change prototype.
	(start_decl): Likewise.
	(start_handler_parms): Likewise.
	(get_scope_of_declarator): Likewise.
	(start_function): Likewise.
	(start_preparsed_function): New function.
	(start_function): Change prototype.
	(start_method): Likewise.
	(grokfield): Likewise.
	(grokbitfield): Likewise.
	(build_new): Likewise.
	(make_pointer_declarator): Remove.
	(make_reference_declarator): Likewise.
	(make_call_declarator): Likewise.
	(set_quals_and_spec): Likewise.
	(process_template_parm): Change prototype.
	(begin_function_definition): Remove.
	(finish_parmlist): Remove.
	* decl.c (groktypename): Do not use trees to represent
	declarators.
	(start_decl): Likewise.
	(start_handler_parms): Remove.
	(get_scope_of_declarator): Reimplement.
	(grokdeclarator): Do not use trees to represent	declarators.
	(grokparms): Likewise.
	(start_function): Likewise.
	(start_method): Likewise.
	(build_void_list_mode): Do not use TREE_PARMLIST.
	* decl.h (grokdeclarator): Change prototype.
	* decl2.c (grok_method_quals): Robustify.
	(grok_x_components): Do not use trees to represent declarators.
	(grokfield): Likewise.
	(grokbitfield): Likewise.
	(start_objects): Build FUNCTION_DECLs, not declarators.
	(start_static_storage_duration_function): Likewise.
	* init.c (build_new): Simplify.
	* lex.c (make_pointer_declarator): Remove.
	(make_reference_declarator): Likewise.
	(make_call_declarator): Likewise.
	(set_quals_and_spec): Likewise.
	* method.c (use_thunk): Use start_preparsed_function.
	(synthesize_method): Likewise.
	(implicitly_declare_fn): Build FUNCTION_DECLs, not declarators.
	* optimize.c (maybe_clone_body): Use start_preparsed_function.
	* parser.c (cp_error_declarator): New variable.
	(declarator_obstack): Likewise.
	(alloc_declarator): New function.
	(make_declarator): Likewise.
	(make_id_declarator): Likewise.
	(make_pointer_declarator): Likewise.
	(make_reference_declarator): Likewise.
	(make_ptrmem_declarator): Likewise.
	(make_call_declarator): Likewise.
	(make_array_declarator): Likewise.
	(no_parameters): New variable.
	(make_parameter_declarator): Likewise.
	(cp_parser_check_for_definition_in_return_type): Do not use trees
	to represent declarators.
	(cp_parser_translation_unit): Likewise.
	(cp_parser_new_expression): Likewise.
	(cp_parser_new_type_id): Likewise.
	(cp_parser_new_declarator_opt): Likewise.
	(cp_parser_direct_new_declarator): Likewise.
	(cp_parser_condition): Likewise.
	(cp_parser_declaration_statement): Likewise.
	(cp_parser_declaration): Likewise.
	(cp_parser_conversion_type_id): Likewise.
	(cp_parser_conversion_declarator_opt): Likewise.
	(cp_parser_template_parameter_list): Likewise.
	(cp_parser_template_parameter): Likewise.
	(cp_parser_explicit_instantiation): Likewise.
	(cp_parser_init_declarator): Likewise.
	(cp_parser_declarator): Likewise.
	(cp_parser_direct_declarator): Likewise.
	(cp_parser_type_id): Likewise.
	(cp_parser_parameter_declaration_clause): Likewise.
	(cp_parser_parameter_declaration_list): Likewise.
	(cp_parser_parameter_declaration): Likewise.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_exception_declaration): Likewise.
	(cp_parser_check_declarator_template_parameters): Likewise.
	(cp_parser_function_definition_from_specifiers_and_declarator):
	Likewise.
	(cp_parser_save_member_function_body): Likewise.
	* pt.c (process_template_parm): Add is_non_type parameter.
	(convert_template_argument): Adjust call to groktypename.
	(tsubst_call_declarator_parms): Remove use of TREE_PARMLIST.
	(tsubst): Do not expect declarators.
	(tsubst_copy_and_build): Adjust NEW_EXPR case to handle additional
	argument.
	(instantiate_decl): Use start_preparsed_function.
	* semantics.c (begin_function_definition): Remove.
	(finish_parmlist): Remove.
	* cp-mudflap.c (mflang_flush_calls): Build FUNCTION_DECLs, not
	declarators.

From-SVN: r83482
This commit is contained in:
Mark Mitchell 2004-06-22 07:18:38 +00:00 committed by Mark Mitchell
parent c0d578e68f
commit 058b15c1dc
14 changed files with 1347 additions and 1434 deletions

View File

@ -1,3 +1,112 @@
2004-06-21 Mark Mitchell <mark@codesourcery.com>
* cp-tree.def (NEW_EXPR): Add a fourth slot.
* cp-tree.h (PARMLIST_ELLIPSIS_P): Remove.
(TREE_PARMLIST): Likewise.
(CALL_DECLARATOR_PARMS): Likewise.
(CALL_DECLARATOR_QUALS): Likewise.
(CALL_DECLARATOR_EXCEPTION_SPEC): Likewise.
(cp_declarator_kind): New type.
(cp_parameter_declarator): Likewise.
(cp_declarator): Likewise.
(cp_error_declarator): Likewise.
(no_parameters): Likewise.
(groktypename): Change prototype.
(start_decl): Likewise.
(start_handler_parms): Likewise.
(get_scope_of_declarator): Likewise.
(start_function): Likewise.
(start_preparsed_function): New function.
(start_function): Change prototype.
(start_method): Likewise.
(grokfield): Likewise.
(grokbitfield): Likewise.
(build_new): Likewise.
(make_pointer_declarator): Remove.
(make_reference_declarator): Likewise.
(make_call_declarator): Likewise.
(set_quals_and_spec): Likewise.
(process_template_parm): Change prototype.
(begin_function_definition): Remove.
(finish_parmlist): Remove.
* decl.c (groktypename): Do not use trees to represent
declarators.
(start_decl): Likewise.
(start_handler_parms): Remove.
(get_scope_of_declarator): Reimplement.
(grokdeclarator): Do not use trees to represent declarators.
(grokparms): Likewise.
(start_function): Likewise.
(start_method): Likewise.
(build_void_list_mode): Do not use TREE_PARMLIST.
* decl.h (grokdeclarator): Change prototype.
* decl2.c (grok_method_quals): Robustify.
(grok_x_components): Do not use trees to represent declarators.
(grokfield): Likewise.
(grokbitfield): Likewise.
(start_objects): Build FUNCTION_DECLs, not declarators.
(start_static_storage_duration_function): Likewise.
* init.c (build_new): Simplify.
* lex.c (make_pointer_declarator): Remove.
(make_reference_declarator): Likewise.
(make_call_declarator): Likewise.
(set_quals_and_spec): Likewise.
* method.c (use_thunk): Use start_preparsed_function.
(synthesize_method): Likewise.
(implicitly_declare_fn): Build FUNCTION_DECLs, not declarators.
* optimize.c (maybe_clone_body): Use start_preparsed_function.
* parser.c (cp_error_declarator): New variable.
(declarator_obstack): Likewise.
(alloc_declarator): New function.
(make_declarator): Likewise.
(make_id_declarator): Likewise.
(make_pointer_declarator): Likewise.
(make_reference_declarator): Likewise.
(make_ptrmem_declarator): Likewise.
(make_call_declarator): Likewise.
(make_array_declarator): Likewise.
(no_parameters): New variable.
(make_parameter_declarator): Likewise.
(cp_parser_check_for_definition_in_return_type): Do not use trees
to represent declarators.
(cp_parser_translation_unit): Likewise.
(cp_parser_new_expression): Likewise.
(cp_parser_new_type_id): Likewise.
(cp_parser_new_declarator_opt): Likewise.
(cp_parser_direct_new_declarator): Likewise.
(cp_parser_condition): Likewise.
(cp_parser_declaration_statement): Likewise.
(cp_parser_declaration): Likewise.
(cp_parser_conversion_type_id): Likewise.
(cp_parser_conversion_declarator_opt): Likewise.
(cp_parser_template_parameter_list): Likewise.
(cp_parser_template_parameter): Likewise.
(cp_parser_explicit_instantiation): Likewise.
(cp_parser_init_declarator): Likewise.
(cp_parser_declarator): Likewise.
(cp_parser_direct_declarator): Likewise.
(cp_parser_type_id): Likewise.
(cp_parser_parameter_declaration_clause): Likewise.
(cp_parser_parameter_declaration_list): Likewise.
(cp_parser_parameter_declaration): Likewise.
(cp_parser_member_declaration): Likewise.
(cp_parser_exception_declaration): Likewise.
(cp_parser_check_declarator_template_parameters): Likewise.
(cp_parser_function_definition_from_specifiers_and_declarator):
Likewise.
(cp_parser_save_member_function_body): Likewise.
* pt.c (process_template_parm): Add is_non_type parameter.
(convert_template_argument): Adjust call to groktypename.
(tsubst_call_declarator_parms): Remove use of TREE_PARMLIST.
(tsubst): Do not expect declarators.
(tsubst_copy_and_build): Adjust NEW_EXPR case to handle additional
argument.
(instantiate_decl): Use start_preparsed_function.
* semantics.c (begin_function_definition): Remove.
(finish_parmlist): Remove.
* cp-mudflap.c (mflang_flush_calls): Build FUNCTION_DECLs, not
declarators.
2004-06-21 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* call.c (build_vfield_ref): Add new operand for COMPONENT_REF.

View File

@ -63,6 +63,7 @@ void
mflang_flush_calls (tree enqueued_call_stmt_chain)
{
tree fnname, fndecl, body;
tree type;
/* Short-circuit! */
if (enqueued_call_stmt_chain == NULL_TREE)
@ -70,11 +71,8 @@ mflang_flush_calls (tree enqueued_call_stmt_chain)
/* Create a ctor function declaration. */
fnname = get_identifier ("__static_initialization_and_destruction_mudflap");
start_function (void_list_node,
make_call_declarator (fnname, void_list_node, NULL_TREE,
NULL_TREE),
NULL_TREE, SF_DEFAULT);
type = build_function_type (void_type_node, void_list_node);
fndecl = build_lang_decl (FUNCTION_DECL, fnname, type);
TREE_PUBLIC (current_function_decl) = 0;
TREE_USED (current_function_decl) = 1;
@ -82,6 +80,7 @@ mflang_flush_calls (tree enqueued_call_stmt_chain)
mf_mark (current_function_decl);
/* Generate the body, one statement at a time. */
start_preparsed_function (fndecl, /*attrs=*/NULL_TREE, SF_PRE_PARSED);
body = begin_compound_stmt (BCS_FN_BODY);
while (enqueued_call_stmt_chain)

View File

@ -51,8 +51,9 @@ DEFTREECODE (PTRMEM_CST, "ptrmem_cst", 'c', 0)
/* For NEW_EXPR, operand 0 is the placement list.
Operand 1 is the new-declarator.
Operand 2 is the initializer. */
DEFTREECODE (NEW_EXPR, "nw_expr", 'e', 3)
Operand 2 is the number of elements in the array.
Operand 3 is the initializer. */
DEFTREECODE (NEW_EXPR, "nw_expr", 'e', 4)
DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", 'e', 3)
/* For DELETE_EXPR, operand 0 is the store to be destroyed.

View File

@ -45,7 +45,6 @@ struct diagnostic_context;
CLEANUP_P (in TRY_BLOCK)
AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF)
PARMLIST_ELLIPSIS_P (in PARMLIST)
DECL_PRETTY_FUNCTION_P (in VAR_DECL)
KOENIG_LOOKUP_P (in CALL_EXPR)
STATEMENT_LIST_NO_SCOPE (in STATEMENT_LIST).
@ -64,7 +63,6 @@ struct diagnostic_context;
TYPE_POLYMORPHIC_P (in _TYPE)
ICS_THIS_FLAG (in _CONV)
BINFO_LOST_PRIMARY_P (in BINFO)
TREE_PARMLIST (in TREE_LIST)
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
STATEMENT_LIST_TRY_BLOCK (in STATEMENT_LIST)
3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE).
@ -1566,13 +1564,6 @@ struct lang_type GTY(())
#define BV_FN(NODE) (TREE_VALUE (NODE))
/* Nonzero for TREE_LIST node means that this list of things
is a list of parameters, as opposed to a list of expressions. */
#define TREE_PARMLIST(NODE) (TREE_LANG_FLAG_2 (NODE))
/* Nonzero for a parmlist means that this parmlist ended in ... */
#define PARMLIST_ELLIPSIS_P(NODE) TREE_LANG_FLAG_0 (NODE)
/* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE
will be NULL_TREE to indicate a throw specification of `()', or
@ -2953,18 +2944,6 @@ struct lang_decl GTY(())
#define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1)
#define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2)
/* The parameters for a call-declarator. */
#define CALL_DECLARATOR_PARMS(NODE) \
(TREE_PURPOSE (TREE_OPERAND (NODE, 1)))
/* The cv-qualifiers for a call-declarator. */
#define CALL_DECLARATOR_QUALS(NODE) \
(TREE_VALUE (TREE_OPERAND (NODE, 1)))
/* The exception-specification for a call-declarator. */
#define CALL_DECLARATOR_EXCEPTION_SPEC(NODE) \
(TREE_TYPE (NODE))
/* An enumeration of the kind of tags that C++ accepts. */
enum tag_types {
none_type = 0, /* Not a tag type. */
@ -3529,6 +3508,89 @@ extern GTY(()) operator_name_info_t operator_name_info
extern GTY(()) operator_name_info_t assignment_operator_name_info
[(int) LAST_CPLUS_TREE_CODE];
/* The various kinds of declarators. */
typedef enum cp_declarator_kind {
cdk_id,
cdk_function,
cdk_array,
cdk_pointer,
cdk_reference,
cdk_ptrmem,
cdk_error
} cp_declarator_kind;
/* A declarator. */
typedef struct cp_declarator cp_declarator;
typedef struct cp_parameter_declarator cp_parameter_declarator;
/* A parameter, before it has been semantically analyzed. */
struct cp_parameter_declarator {
/* The next parameter, or NULL_TREE if none. */
cp_parameter_declarator *next;
/* The decl-specifiers-seq for the parameter. */
tree decl_specifiers;
/* The declarator for the parameter. */
cp_declarator *declarator;
/* The default-argument expression, or NULL_TREE, if none. */
tree default_argument;
/* True iff this is the first parameter in the list and the
parameter sequence ends with an ellipsis. */
bool ellipsis_p;
};
/* A declarator. */
struct cp_declarator {
/* The kind of declarator. */
cp_declarator_kind kind;
/* Attributes that apply to this declarator. */
tree attributes;
/* For all but cdk_id and cdk_error, the contained declarator. For
cdk_id and cdk_error, guaranteed to be NULL. */
cp_declarator *declarator;
union {
/* For identifiers. */
struct {
/* The name of the function -- an IDENTIFIER_NODE, BIT_NOT_EXPR,
TEMPLATE_ID_EXPR, or SCOPE_REF. */
tree name;
/* If this is the name of a function, what kind of special
function (if any). */
special_function_kind sfk;
} id;
/* For functions. */
struct {
/* The parameters to the function. */
cp_parameter_declarator *parameters;
/* The cv-qualifiers for the function. */
tree qualifiers;
/* The exception-specification for the function. */
tree exception_specification;
} function;
/* For arrays. */
struct {
/* The bounds to the array. */
tree bounds;
} array;
/* For cdk_pointer, cdk_reference, and cdk_ptrmem. */
struct {
/* The cv-qualifiers for the pointer. */
tree qualifiers;
/* For cdk_ptrmem, the class type containing the member. */
tree class_type;
} pointer;
} u;
};
/* An erroneous declarator. */
extern cp_declarator *cp_error_declarator;
/* A parameter list indicating for a function with no parameters,
e.g "int f(void)". */
extern cp_parameter_declarator *no_parameters;
/* in call.c */
extern bool check_dtor_name (tree, tree);
@ -3674,19 +3736,18 @@ extern tree push_throw_library_fn (tree, tree);
extern int init_type_desc (void);
extern tree check_tag_decl (tree);
extern tree shadow_tag (tree);
extern tree groktypename (tree);
extern tree start_decl (tree, tree, int, tree, tree);
extern tree groktypename (tree, const cp_declarator *);
extern tree start_decl (const cp_declarator *, tree, int, tree, tree);
extern void start_decl_1 (tree);
extern void cp_finish_decl (tree, tree, tree, int);
extern void finish_decl (tree, tree, tree);
extern void maybe_inject_for_scope_var (tree);
extern tree start_handler_parms (tree, tree);
extern int complete_array_type (tree, tree, int);
extern tree build_ptrmemfunc_type (tree);
extern tree build_ptrmem_type (tree, tree);
/* the grokdeclarator prototype is in decl.h */
extern int copy_fn_p (tree);
extern tree get_scope_of_declarator (tree);
extern tree get_scope_of_declarator (const cp_declarator *);
extern void grok_special_member_properties (tree);
extern int grok_ctor_properties (tree, tree);
extern bool grok_op_properties (tree, int, bool);
@ -3696,11 +3757,12 @@ extern void xref_basetypes (tree, tree);
extern tree start_enum (tree);
extern void finish_enum (tree);
extern void build_enumerator (tree, tree, tree);
extern int start_function (tree, tree, tree, int);
extern void start_preparsed_function (tree, tree, int);
extern int start_function (tree, const cp_declarator *, tree);
extern tree begin_function_body (void);
extern void finish_function_body (tree);
extern tree finish_function (int);
extern tree start_method (tree, tree, tree);
extern tree start_method (tree, const cp_declarator *, tree);
extern tree finish_method (tree);
extern void maybe_register_incomplete_var (tree);
extern void complete_vars (tree);
@ -3749,8 +3811,8 @@ extern tree grok_array_decl (tree, tree);
extern tree delete_sanity (tree, tree, bool, int);
extern tree check_classfn (tree, tree, tree);
extern void check_member_template (tree);
extern tree grokfield (tree, tree, tree, tree, tree);
extern tree grokbitfield (tree, tree, tree);
extern tree grokfield (const cp_declarator *, tree, tree, tree, tree);
extern tree grokbitfield (const cp_declarator *, tree, tree);
extern tree groktypefield (tree, tree);
extern void cplus_decl_attributes (tree *, tree, int);
extern void finish_anon_union (tree);
@ -3828,7 +3890,7 @@ extern tree get_aggr_from_typedef (tree, int);
extern tree get_type_value (tree);
extern tree build_zero_init (tree, tree, bool);
extern tree build_offset_ref (tree, tree, bool);
extern tree build_new (tree, tree, tree, int);
extern tree build_new (tree, tree, tree, tree, int);
extern tree build_vec_init (tree, tree, tree, int);
extern tree build_x_delete (tree, int, tree);
extern tree build_delete (tree, tree, special_function_kind, int, int);
@ -3839,14 +3901,8 @@ extern tree create_temporary_var (tree);
extern void initialize_vtbl_ptrs (tree);
extern tree build_java_class_ref (tree);
/* in input.c */
/* in lex.c */
extern void cxx_dup_lang_specific_decl (tree);
extern tree make_pointer_declarator (tree, tree);
extern tree make_reference_declarator (tree, tree);
extern tree make_call_declarator (tree, tree, tree, tree);
extern void set_quals_and_spec (tree, tree, tree);
extern void print_parse_statistics (void);
extern void do_pending_inlines (void);
extern void yyungetc (int, int);
@ -3892,7 +3948,7 @@ extern void end_specialization (void);
extern void begin_explicit_instantiation (void);
extern void end_explicit_instantiation (void);
extern tree check_explicit_specialization (tree, tree, int, int);
extern tree process_template_parm (tree, tree);
extern tree process_template_parm (tree, tree, bool);
extern tree end_template_parm_list (tree);
extern void end_template_decl (void);
extern tree current_template_args (void);
@ -4095,11 +4151,9 @@ extern tree finish_pseudo_destructor_expr (tree, tree, tree);
extern tree finish_unary_op_expr (enum tree_code, tree);
extern tree finish_compound_literal (tree, tree);
extern tree finish_fname (tree);
extern int begin_function_definition (tree, tree, tree);
extern void finish_translation_unit (void);
extern tree finish_template_type_parm (tree, tree);
extern tree finish_template_template_parm (tree, tree);
extern tree finish_parmlist (tree, int);
extern tree begin_class_definition (tree);
extern void finish_default_args (void);
extern tree finish_member_class_template (tree);

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ enum decl_context
};
/* We need this in here to get the decl_context definition. */
extern tree grokdeclarator (tree, tree, enum decl_context, int, tree*);
extern tree grokdeclarator (const cp_declarator *, tree, enum decl_context, int, tree*);
#ifdef DEBUG_CP_BINDING_LEVELS
/* Purely for debugging purposes. */

View File

@ -127,7 +127,7 @@ grok_method_quals (tree ctype, tree function, tree quals)
int dup_quals = TYPE_UNQUALIFIED;
int this_quals = TYPE_UNQUALIFIED;
do
while (quals)
{
int tq = cp_type_qual_from_rid (TREE_VALUE (quals));
@ -139,7 +139,6 @@ grok_method_quals (tree ctype, tree function, tree quals)
type_quals |= tq;
quals = TREE_CHAIN (quals);
}
while (quals);
if (dup_quals != TYPE_UNQUALIFIED)
error ("duplicate type qualifiers in %s declaration",
@ -168,7 +167,7 @@ grok_x_components (tree specs)
specs = strip_attrs (specs);
check_tag_decl (specs);
t = groktypename (build_tree_list (specs, NULL_TREE));
t = groktypename (specs, /*declarator=*/NULL);
/* The only case where we need to do anything additional here is an
anonymous union field, e.g.: `struct S { union { int i; }; };'. */
@ -841,7 +840,8 @@ finish_static_data_member_decl (tree decl, tree init, tree asmspec_tree,
CHANGES TO CODE IN `start_method'. */
tree
grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
grokfield (const cp_declarator *declarator, tree declspecs,
tree init, tree asmspec_tree,
tree attrlist)
{
tree value;
@ -849,15 +849,18 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
int flags = LOOKUP_ONLYCONVERTING;
if (declspecs == NULL_TREE
&& TREE_CODE (declarator) == SCOPE_REF
&& TREE_CODE (TREE_OPERAND (declarator, 1)) == IDENTIFIER_NODE)
&& declarator->kind == cdk_id
&& TREE_CODE (declarator->u.id.name) == SCOPE_REF
&& (TREE_CODE (TREE_OPERAND (declarator->u.id.name, 1))
== IDENTIFIER_NODE))
{
/* Access declaration */
if (! IS_AGGR_TYPE_CODE (TREE_CODE (TREE_OPERAND (declarator, 0))))
if (! IS_AGGR_TYPE_CODE (TREE_CODE
(TREE_OPERAND (declarator->u.id.name, 0))))
;
else if (TREE_COMPLEXITY (declarator) == current_class_depth)
else if (TREE_COMPLEXITY (declarator->u.id.name) == current_class_depth)
pop_nested_class ();
return do_class_using_decl (declarator);
return do_class_using_decl (declarator->u.id.name);
}
if (init
@ -1020,7 +1023,7 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node. */
tree
grokbitfield (tree declarator, tree declspecs, tree width)
grokbitfield (const cp_declarator *declarator, tree declspecs, tree width)
{
tree value = grokdeclarator (declarator, declspecs, BITFIELD, 0, NULL);
@ -1915,8 +1918,8 @@ set_guard (tree guard)
static tree
start_objects (int method_type, int initp)
{
tree fnname;
tree body;
tree fndecl;
char type[10];
/* Make ctor or dtor function. METHOD_TYPE may be 'I' or 'D'. */
@ -1936,12 +1939,11 @@ start_objects (int method_type, int initp)
else
sprintf (type, "%c", method_type);
fnname = get_file_function_name_long (type);
start_function (void_list_node,
make_call_declarator (fnname, void_list_node, NULL_TREE,
NULL_TREE),
NULL_TREE, SF_DEFAULT);
fndecl = build_lang_decl (FUNCTION_DECL,
get_file_function_name_long (type),
build_function_type (void_type_node,
void_list_node));
start_preparsed_function (fndecl, /*attrs=*/NULL_TREE, SF_PRE_PARSED);
/* It can be a static function as long as collect2 does not have
to scan the object file to find its ctor/dtor routine. */
@ -2108,10 +2110,9 @@ start_static_storage_duration_function (unsigned count)
It is static because we only need to call this function from the
various constructor and destructor functions for this module. */
start_function (/*specs=*/NULL_TREE,
ssdf_decl,
/*attrs=*/NULL_TREE,
SF_PRE_PARSED);
start_preparsed_function (ssdf_decl,
/*attrs=*/NULL_TREE,
SF_PRE_PARSED);
/* Set up the scope of the outermost block in the function. */
body = begin_compound_stmt (BCS_FN_BODY);

View File

@ -1665,126 +1665,18 @@ build_builtin_delete_call (tree addr)
PLACEMENT is the `placement' list for user-defined operator new (). */
tree
build_new (tree placement, tree decl, tree init, int use_global_new)
build_new (tree placement, tree type, tree nelts, tree init,
int use_global_new)
{
tree type, rval;
tree nelts = NULL_TREE, t;
int has_array = 0;
tree rval;
if (decl == error_mark_node)
if (type == error_mark_node)
return error_mark_node;
if (TREE_CODE (decl) == TREE_LIST)
{
tree absdcl = TREE_VALUE (decl);
tree last_absdcl = NULL_TREE;
if (current_function_decl
&& DECL_CONSTRUCTOR_P (current_function_decl))
my_friendly_assert (immediate_size_expand == 0, 19990926);
nelts = integer_one_node;
if (absdcl && TREE_CODE (absdcl) == CALL_EXPR)
abort ();
while (absdcl && TREE_CODE (absdcl) == INDIRECT_REF)
{
last_absdcl = absdcl;
absdcl = TREE_OPERAND (absdcl, 0);
}
if (absdcl && TREE_CODE (absdcl) == ARRAY_REF)
{
/* Probably meant to be a vec new. */
tree this_nelts;
while (TREE_OPERAND (absdcl, 0)
&& TREE_CODE (TREE_OPERAND (absdcl, 0)) == ARRAY_REF)
{
last_absdcl = absdcl;
absdcl = TREE_OPERAND (absdcl, 0);
}
has_array = 1;
this_nelts = TREE_OPERAND (absdcl, 1);
if (this_nelts != error_mark_node)
{
if (this_nelts == NULL_TREE)
error ("new of array type fails to specify size");
else if (processing_template_decl)
{
nelts = this_nelts;
absdcl = TREE_OPERAND (absdcl, 0);
}
else
{
if (build_expr_type_conversion (WANT_INT | WANT_ENUM,
this_nelts, false)
== NULL_TREE)
pedwarn ("size in array new must have integral type");
this_nelts = save_expr (cp_convert (sizetype, this_nelts));
absdcl = TREE_OPERAND (absdcl, 0);
if (this_nelts == integer_zero_node)
{
warning ("zero size array reserves no space");
nelts = integer_zero_node;
}
else
nelts = cp_build_binary_op (MULT_EXPR, nelts, this_nelts);
}
}
else
nelts = integer_zero_node;
}
if (last_absdcl)
TREE_OPERAND (last_absdcl, 0) = absdcl;
else
TREE_VALUE (decl) = absdcl;
type = groktypename (decl);
if (! type || type == error_mark_node)
return error_mark_node;
}
else if (TREE_CODE (decl) == IDENTIFIER_NODE)
{
if (IDENTIFIER_HAS_TYPE_VALUE (decl))
{
/* An aggregate type. */
type = IDENTIFIER_TYPE_VALUE (decl);
decl = TYPE_MAIN_DECL (type);
}
else
{
/* A builtin type. */
decl = lookup_name (decl, 1);
my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 215);
type = TREE_TYPE (decl);
}
}
else if (TREE_CODE (decl) == TYPE_DECL)
{
type = TREE_TYPE (decl);
}
else
{
type = decl;
decl = TYPE_MAIN_DECL (type);
}
if (processing_template_decl)
{
if (has_array)
t = tree_cons (tree_cons (NULL_TREE, type, NULL_TREE),
build_min_nt (ARRAY_REF, NULL_TREE, nelts,
NULL_TREE, NULL_TREE),
NULL_TREE);
else
t = type;
rval = build_min (NEW_EXPR, build_pointer_type (type),
placement, t, init);
placement, type, nelts, init);
NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
TREE_SIDE_EFFECTS (rval) = 1;
return rval;
@ -1805,22 +1697,8 @@ build_new (tree placement, tree decl, tree init, int use_global_new)
return error_mark_node;
}
/* When the object being created is an array, the new-expression yields a
pointer to the initial element (if any) of the array. For example,
both new int and new int[10] return an int*. 5.3.4. */
if (TREE_CODE (type) == ARRAY_TYPE && has_array == 0)
{
nelts = array_type_nelts_top (type);
has_array = 1;
type = TREE_TYPE (type);
}
if (has_array)
t = build_nt (ARRAY_REF, type, nelts, NULL_TREE, NULL_TREE);
else
t = type;
rval = build (NEW_EXPR, build_pointer_type (type), placement, t, init);
rval = build (NEW_EXPR, build_pointer_type (type), placement, type,
nelts, init);
NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
TREE_SIDE_EFFECTS (rval) = 1;
rval = build_new_1 (rval);
@ -1957,15 +1835,14 @@ build_new_1 (tree exp)
placement = TREE_OPERAND (exp, 0);
type = TREE_OPERAND (exp, 1);
init = TREE_OPERAND (exp, 2);
nelts = TREE_OPERAND (exp, 2);
init = TREE_OPERAND (exp, 3);
globally_qualified_p = NEW_EXPR_USE_GLOBAL (exp);
if (TREE_CODE (type) == ARRAY_REF)
if (nelts)
{
has_array = 1;
nelts = outer_nelts = TREE_OPERAND (type, 1);
type = TREE_OPERAND (type, 0);
outer_nelts = nelts;
/* Use an incomplete array type to avoid VLA headaches. */
full_type = build_cplus_array_type (type, NULL_TREE);
}

View File

@ -82,62 +82,6 @@ struct impl_files
static struct impl_files *impl_file_chain;
/* Return something to represent absolute declarators containing a *.
TARGET is the absolute declarator that the * contains.
CV_QUALIFIERS is a list of modifiers such as const or volatile
to apply to the pointer type, represented as identifiers.
We return an INDIRECT_REF whose "contents" are TARGET
and whose type is the modifier list. */
tree
make_pointer_declarator (tree cv_qualifiers, tree target)
{
if (target && TREE_CODE (target) == IDENTIFIER_NODE
&& ANON_AGGRNAME_P (target))
error ("type name expected before `*'");
target = build_nt (INDIRECT_REF, target);
TREE_TYPE (target) = cv_qualifiers;
return target;
}
/* Return something to represent absolute declarators containing a &.
TARGET is the absolute declarator that the & contains.
CV_QUALIFIERS is a list of modifiers such as const or volatile
to apply to the reference type, represented as identifiers.
We return an ADDR_EXPR whose "contents" are TARGET
and whose type is the modifier list. */
tree
make_reference_declarator (tree cv_qualifiers, tree target)
{
target = build_nt (ADDR_EXPR, target);
TREE_TYPE (target) = cv_qualifiers;
return target;
}
tree
make_call_declarator (tree target, tree parms, tree cv_qualifiers,
tree exception_specification)
{
target = build_nt (CALL_EXPR, target,
tree_cons (parms, cv_qualifiers, NULL_TREE),
/* The third operand is really RTL. We
shouldn't put anything there. */
NULL_TREE);
CALL_DECLARATOR_EXCEPTION_SPEC (target) = exception_specification;
return target;
}
void
set_quals_and_spec (tree call_declarator, tree cv_qualifiers,
tree exception_specification)
{
CALL_DECLARATOR_QUALS (call_declarator) = cv_qualifiers;
CALL_DECLARATOR_EXCEPTION_SPEC (call_declarator) = exception_specification;
}
int interface_only; /* whether or not current file is only for
interface definitions. */

View File

@ -448,7 +448,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
DECL_RESULT (thunk_fndecl) = NULL_TREE;
start_function (NULL_TREE, thunk_fndecl, NULL_TREE, SF_PRE_PARSED);
start_preparsed_function (thunk_fndecl, NULL_TREE, SF_PRE_PARSED);
/* We don't bother with a body block for thunks. */
/* There's no need to check accessibility inside the thunk body. */
@ -742,7 +742,7 @@ synthesize_method (tree fndecl)
DECL_SOURCE_LOCATION (fndecl) = input_location;
interface_unknown = 1;
start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
start_preparsed_function (fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
clear_last_expr ();
stmt = begin_function_body ();
@ -937,56 +937,56 @@ locate_copy (tree type, void *client_)
tree
implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
{
tree declspecs = NULL_TREE;
tree fn, args = NULL_TREE;
tree fn;
tree parameter_types = void_list_node;
tree return_type = void_type_node;
tree fn_type;
tree raises = empty_except_spec;
bool retref = false;
bool has_parm = false;
tree name = constructor_name (type);
tree rhs_parm_type = NULL_TREE;
tree name;
switch (kind)
{
case sfk_destructor:
/* Destructor. */
name = build_nt (BIT_NOT_EXPR, name);
args = void_list_node;
name = constructor_name (type);
raises = synthesize_exception_spec (type, &locate_dtor, 0);
break;
case sfk_constructor:
/* Default constructor. */
args = void_list_node;
name = constructor_name (type);
raises = synthesize_exception_spec (type, &locate_ctor, 0);
TYPE_HAS_CONSTRUCTOR (type) = 1;
break;
case sfk_copy_constructor:
TYPE_HAS_CONSTRUCTOR (type) = 1;
/* Fall through. */
case sfk_assignment_operator:
{
struct copy_data data;
tree argtype = type;
has_parm = true;
data.name = NULL;
data.quals = 0;
if (kind == sfk_assignment_operator)
{
retref = true;
declspecs = build_tree_list (NULL_TREE, type);
return_type = build_reference_type (type);
name = ansi_assopname (NOP_EXPR);
data.name = name;
}
else
name = constructor_name (type);
if (const_p)
{
data.quals = TYPE_QUAL_CONST;
argtype = build_qualified_type (argtype, TYPE_QUAL_CONST);
rhs_parm_type = build_qualified_type (type, TYPE_QUAL_CONST);
}
argtype = build_reference_type (argtype);
args = build_tree_list (hash_tree_chain (argtype, NULL_TREE),
get_identifier ("_ctor_arg"));
args = tree_cons (NULL_TREE, args, void_list_node);
else
rhs_parm_type = type;
rhs_parm_type = build_reference_type (rhs_parm_type);
parameter_types = tree_cons (NULL_TREE, rhs_parm_type, parameter_types);
raises = synthesize_exception_spec (type, &locate_copy, &data);
break;
}
@ -994,21 +994,37 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
abort ();
}
TREE_PARMLIST (args) = 1;
{
tree declarator = make_call_declarator (name, args, NULL_TREE, raises);
if (retref)
declarator = build_nt (ADDR_EXPR, declarator);
fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
if (has_parm)
TREE_USED (FUNCTION_FIRST_USER_PARM (fn)) = 1;
}
my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 20000408);
/* Create the function. */
fn_type = build_method_type_directly (type, return_type, parameter_types);
if (raises)
fn_type = build_exception_variant (fn_type, raises);
fn = build_lang_decl (FUNCTION_DECL, name, fn_type);
if (kind == sfk_constructor || kind == sfk_copy_constructor)
DECL_CONSTRUCTOR_P (fn) = 1;
else if (kind == sfk_destructor)
DECL_DESTRUCTOR_P (fn) = 1;
else
{
DECL_ASSIGNMENT_OPERATOR_P (fn) = 1;
SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR);
}
/* Create the argument list. The call to "grokclassfn" will add the
"this" parameter and any other implicit parameters. */
if (rhs_parm_type)
{
/* Note that this parameter is *not* marked DECL_ARTIFICIAL; we
want its type to be included in the mangled function
name. */
DECL_ARGUMENTS (fn) = cp_build_parm_decl (NULL_TREE, rhs_parm_type);
TREE_READONLY (DECL_ARGUMENTS (fn)) = 1;
}
grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL,
/*quals=*/NULL_TREE);
grok_special_member_properties (fn);
cp_finish_decl (fn, /*init=*/NULL_TREE, /*asmspec_tree=*/NULL_TREE,
/*flags=*/LOOKUP_ONLYCONVERTING);
DECL_IN_AGGR_P (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
DECL_NOT_REALLY_EXTERN (fn) = 1;
DECL_DECLARED_INLINE_P (fn) = 1;

View File

@ -132,7 +132,7 @@ maybe_clone_body (tree fn)
/* Start processing the function. */
push_to_top_level ();
start_function (NULL_TREE, clone, NULL_TREE, SF_PRE_PARSED);
start_preparsed_function (clone, NULL_TREE, SF_PRE_PARSED);
/* Remap the parameters. */
decl_map = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);

File diff suppressed because it is too large Load Diff

View File

@ -2161,21 +2161,20 @@ reduce_template_parm_level (tree index, tree type, int levels)
}
/* Process information from new template parameter NEXT and append it to the
LIST being built. */
LIST being built. This new parameter is a non-type parameter iff
IS_NON_TYPE is true. */
tree
process_template_parm (tree list, tree next)
process_template_parm (tree list, tree next, bool is_non_type)
{
tree parm;
tree decl = 0;
tree defval;
int is_type, idx;
int idx;
parm = next;
my_friendly_assert (TREE_CODE (parm) == TREE_LIST, 259);
defval = TREE_PURPOSE (parm);
parm = TREE_VALUE (parm);
is_type = TREE_PURPOSE (parm) == class_type_node;
if (list)
{
@ -2190,12 +2189,10 @@ process_template_parm (tree list, tree next)
else
idx = 0;
if (!is_type)
if (is_non_type)
{
my_friendly_assert (TREE_CODE (TREE_PURPOSE (parm)) == TREE_LIST, 260);
/* is a const-param */
parm = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm),
PARM, 0, NULL);
parm = TREE_VALUE (parm);
SET_DECL_TEMPLATE_PARM_P (parm);
/* [temp.param]
@ -2222,7 +2219,7 @@ process_template_parm (tree list, tree next)
else
{
tree t;
parm = TREE_VALUE (parm);
parm = TREE_VALUE (TREE_VALUE (parm));
if (parm && TREE_CODE (parm) == TEMPLATE_DECL)
{
@ -3757,7 +3754,7 @@ convert_template_argument (tree parm,
}
}
else
val = groktypename (arg);
val = arg;
}
else
{
@ -6600,9 +6597,6 @@ tsubst_call_declarator_parms (tree parms,
doesn't check TREE_PARMLIST. */
new_parms = tree_cons (defarg, type, new_parms);
/* And note that these are parameters. */
TREE_PARMLIST (new_parms) = 1;
return new_parms;
}
@ -6852,7 +6846,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case TREE_LIST:
{
tree purpose, value, chain, result;
tree purpose, value, chain;
if (t == void_list_node)
return t;
@ -6882,14 +6876,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
&& value == TREE_VALUE (t)
&& chain == TREE_CHAIN (t))
return t;
if (TREE_PARMLIST (t))
{
result = tree_cons (purpose, value, chain);
TREE_PARMLIST (result) = 1;
}
else
result = hash_tree_cons (purpose, value, chain);
return result;
return hash_tree_cons (purpose, value, chain);
}
case TREE_VEC:
if (type != NULL_TREE)
@ -7179,20 +7166,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
}
case INDIRECT_REF:
{
tree e = tsubst (TREE_OPERAND (t, 0), args, complain, in_decl);
if (e == error_mark_node)
return error_mark_node;
return make_pointer_declarator (type, e);
}
case ADDR_EXPR:
{
tree e = tsubst (TREE_OPERAND (t, 0), args, complain, in_decl);
if (e == error_mark_node)
return error_mark_node;
return make_reference_declarator (type, e);
}
case CALL_EXPR:
abort ();
case ARRAY_REF:
{
@ -7204,21 +7180,6 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
return build_nt (ARRAY_REF, e1, e2, NULL_TREE, NULL_TREE);
}
case CALL_EXPR:
{
tree e1 = tsubst (TREE_OPERAND (t, 0), args, complain, in_decl);
tree e2 = (tsubst_call_declarator_parms
(CALL_DECLARATOR_PARMS (t), args, complain, in_decl));
tree e3 = tsubst (CALL_DECLARATOR_EXCEPTION_SPEC (t), args,
complain, in_decl);
if (e1 == error_mark_node || e2 == error_mark_node
|| e3 == error_mark_node)
return error_mark_node;
return make_call_declarator (e1, e2, CALL_DECLARATOR_QUALS (t), e3);
}
case SCOPE_REF:
{
tree e1 = tsubst (TREE_OPERAND (t, 0), args, complain, in_decl);
@ -8306,6 +8267,7 @@ tsubst_copy_and_build (tree t,
(RECUR (TREE_OPERAND (t, 0)),
RECUR (TREE_OPERAND (t, 1)),
RECUR (TREE_OPERAND (t, 2)),
RECUR (TREE_OPERAND (t, 3)),
NEW_EXPR_USE_GLOBAL (t));
case DELETE_EXPR:
@ -11198,7 +11160,7 @@ instantiate_decl (tree d, int defer_ok, int undefined_ok)
/* Set up context. */
import_export_decl (d);
start_function (NULL_TREE, d, NULL_TREE, SF_PRE_PARSED);
start_preparsed_function (d, NULL_TREE, SF_PRE_PARSED);
/* Create substitution entries for the parameters. */
subst_decl = DECL_TEMPLATE_RESULT (template_for_substitution (d));

View File

@ -1900,23 +1900,6 @@ finish_fname (tree id)
return decl;
}
/* Begin a function definition declared with DECL_SPECS, ATTRIBUTES,
and DECLARATOR. Returns nonzero if the function-declaration is
valid. */
int
begin_function_definition (tree decl_specs, tree attributes, tree declarator)
{
if (!start_function (decl_specs, declarator, attributes, SF_DEFAULT))
return 0;
/* The things we're about to see are not directly qualified by any
template headers we've seen thus far. */
reset_specialization ();
return 1;
}
/* Finish a translation unit. */
void
@ -1998,24 +1981,6 @@ check_template_template_default_arg (tree argument)
return argument;
}
/* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
nonzero, the parameter list was terminated by a `...'. */
tree
finish_parmlist (tree parms, int ellipsis)
{
if (parms)
{
/* We mark the PARMS as a parmlist so that declarator processing can
disambiguate certain constructs. */
TREE_PARMLIST (parms) = 1;
/* We do not append void_list_node here, but leave it to grokparms
to do that. */
PARMLIST_ELLIPSIS_P (parms) = ellipsis;
}
return parms;
}
/* Begin a class definition, as indicated by T. */
tree