Commit 7a8f9fa9 by Jason Merrill

decl2.c (finish_objects): Don't use .?tors.* if we don't have ASM_OUTPUT_CONSTRUCTOR.

	* decl2.c (finish_objects): Don't use .?tors.* if we don't have
	ASM_OUTPUT_CONSTRUCTOR.
	* friend.c (do_friend): Add attrlist arg.  Remove support for
	getting a non-decl as 'decl'.
	* decl.c (grokfndecl): Remove attrlist arg.  Don't set attrs or
	rtl.
	(grokdeclarator): Adjust.
	* cp-tree.h: Adjust.
	* parse.y (direct_new_declarator): Make the first one a
	nonmomentary_expr, too.
	* init.c (build_new): suspend_momentary while we're calculating
	the size.
	(build_new_1): Don't copy size.

From-SVN: r26952
parent 88b117b7
1999-05-16 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (finish_objects): Don't use .?tors.* if we don't have
ASM_OUTPUT_CONSTRUCTOR.
* friend.c (do_friend): Add attrlist arg. Remove support for
getting a non-decl as 'decl'.
* decl.c (grokfndecl): Remove attrlist arg. Don't set attrs or
rtl.
(grokdeclarator): Adjust.
* cp-tree.h: Adjust.
* parse.y (direct_new_declarator): Make the first one a
nonmomentary_expr, too.
* init.c (build_new): suspend_momentary while we're calculating
the size.
(build_new_1): Don't copy size.
1999-05-16 Mark Mitchell <mark@codesourcery.com> 1999-05-16 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (permanent_p): New function. * cp-tree.h (permanent_p): New function.
...@@ -209,7 +227,7 @@ Wed Apr 28 11:42:22 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de> ...@@ -209,7 +227,7 @@ Wed Apr 28 11:42:22 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
* cp-tree.h (lang_decl_flags): Remove returns_first_arg and * cp-tree.h (lang_decl_flags): Remove returns_first_arg and
preserves_first_arg. Enlarge dummy accordingly. preserves_first_arg. Enlarge dummy accordingly.
(DECL_TINFO_FN_P): New macro. (DECL_TINFO_FN_P): New macro.
(SET_DECL_TINO_FN_P): Likeiwse. (SET_DECL_TINFO_FN_P): Likeiwse.
(DECL_RETURNS_FIRST_ARG): Remove. (DECL_RETURNS_FIRST_ARG): Remove.
(DECL_PRESERVES_THIS): Likewise. (DECL_PRESERVES_THIS): Likewise.
(DECL_INIT_PRIORITY): New macro. (DECL_INIT_PRIORITY): New macro.
......
...@@ -3016,7 +3016,7 @@ extern int is_friend PROTO((tree, tree)); ...@@ -3016,7 +3016,7 @@ extern int is_friend PROTO((tree, tree));
extern void make_friend_class PROTO((tree, tree)); extern void make_friend_class PROTO((tree, tree));
extern void add_friend PROTO((tree, tree)); extern void add_friend PROTO((tree, tree));
extern void add_friends PROTO((tree, tree, tree)); extern void add_friends PROTO((tree, tree, tree));
extern tree do_friend PROTO((tree, tree, tree, tree, enum overload_flags, tree, int)); extern tree do_friend PROTO((tree, tree, tree, tree, tree, enum overload_flags, tree, int));
/* in init.c */ /* in init.c */
extern void init_init_processing PROTO((void)); extern void init_init_processing PROTO((void));
......
...@@ -161,7 +161,7 @@ static void warn_extern_redeclared_static PROTO((tree, tree)); ...@@ -161,7 +161,7 @@ static void warn_extern_redeclared_static PROTO((tree, tree));
static void grok_reference_init PROTO((tree, tree, tree)); static void grok_reference_init PROTO((tree, tree, tree));
static tree grokfndecl PROTO((tree, tree, tree, tree, int, static tree grokfndecl PROTO((tree, tree, tree, tree, int,
enum overload_flags, tree, enum overload_flags, tree,
tree, tree, int, int, int, int, int, int, tree)); tree, int, int, int, int, int, int, tree));
static tree grokvardecl PROTO((tree, tree, RID_BIT_TYPE *, int, int, tree)); static tree grokvardecl PROTO((tree, tree, RID_BIT_TYPE *, int, int, tree));
static tree lookup_tag PROTO((enum tree_code, tree, static tree lookup_tag PROTO((enum tree_code, tree,
struct binding_level *, int)); struct binding_level *, int));
...@@ -8697,14 +8697,14 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises) ...@@ -8697,14 +8697,14 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
static tree static tree
grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
raises, attrlist, check, friendp, publicp, inlinep, funcdef_flag, raises, check, friendp, publicp, inlinep, funcdef_flag,
template_count, in_namespace) template_count, in_namespace)
tree ctype, type; tree ctype, type;
tree declarator; tree declarator;
tree orig_declarator; tree orig_declarator;
int virtualp; int virtualp;
enum overload_flags flags; enum overload_flags flags;
tree quals, raises, attrlist; tree quals, raises;
int check, friendp, publicp, inlinep, funcdef_flag, template_count; int check, friendp, publicp, inlinep, funcdef_flag, template_count;
tree in_namespace; tree in_namespace;
{ {
...@@ -8868,10 +8868,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, ...@@ -8868,10 +8868,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
tentative. error_mark_node is replaced later with the BLOCK. */ tentative. error_mark_node is replaced later with the BLOCK. */
DECL_INITIAL (decl) = error_mark_node; DECL_INITIAL (decl) = error_mark_node;
if (attrlist)
cplus_decl_attributes (decl, TREE_PURPOSE (attrlist),
TREE_VALUE (attrlist));
/* Caller will do the rest of this. */ /* Caller will do the rest of this. */
if (check < 0) if (check < 0)
return decl; return decl;
...@@ -8964,8 +8960,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, ...@@ -8964,8 +8960,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
if (ctype == NULL_TREE || check) if (ctype == NULL_TREE || check)
return decl; return decl;
make_decl_rtl (decl, NULL_PTR, 1);
if (virtualp) if (virtualp)
{ {
DECL_VIRTUAL_P (decl) = 1; DECL_VIRTUAL_P (decl) = 1;
...@@ -11306,7 +11300,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -11306,7 +11300,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
TREE_CODE (declarator) != TEMPLATE_ID_EXPR TREE_CODE (declarator) != TEMPLATE_ID_EXPR
? declarator : dname, ? declarator : dname,
declarator, declarator,
virtualp, flags, quals, raises, attrlist, virtualp, flags, quals, raises,
friendp ? -1 : 0, friendp, publicp, inlinep, friendp ? -1 : 0, friendp, publicp, inlinep,
funcdef_flag, template_count, in_namespace); funcdef_flag, template_count, in_namespace);
if (decl == NULL_TREE) if (decl == NULL_TREE)
...@@ -11356,7 +11350,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -11356,7 +11350,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
/* All method decls are public, so tell grokfndecl to set /* All method decls are public, so tell grokfndecl to set
TREE_PUBLIC, also. */ TREE_PUBLIC, also. */
decl = grokfndecl (ctype, type, declarator, declarator, decl = grokfndecl (ctype, type, declarator, declarator,
virtualp, flags, quals, raises, attrlist, virtualp, flags, quals, raises,
friendp ? -1 : 0, friendp, 1, 0, funcdef_flag, friendp ? -1 : 0, friendp, 1, 0, funcdef_flag,
template_count, in_namespace); template_count, in_namespace);
if (decl == NULL_TREE) if (decl == NULL_TREE)
...@@ -11416,7 +11410,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -11416,7 +11410,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
} }
t = do_friend (ctype, declarator, decl, t = do_friend (ctype, declarator, decl,
last_function_parms, flags, quals, last_function_parms, attrlist, flags, quals,
funcdef_flag); funcdef_flag);
} }
if (t && funcdef_flag) if (t && funcdef_flag)
...@@ -11549,7 +11543,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -11549,7 +11543,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|| !RIDBIT_SETP (RID_STATIC, specbits)); || !RIDBIT_SETP (RID_STATIC, specbits));
decl = grokfndecl (ctype, type, original_name, declarator, decl = grokfndecl (ctype, type, original_name, declarator,
virtualp, flags, quals, raises, attrlist, virtualp, flags, quals, raises,
1, friendp, 1, friendp,
publicp, inlinep, funcdef_flag, publicp, inlinep, funcdef_flag,
template_count, in_namespace); template_count, in_namespace);
......
...@@ -2950,7 +2950,7 @@ finish_objects (method_type, initp) ...@@ -2950,7 +2950,7 @@ finish_objects (method_type, initp)
assemble_destructor (fnname); assemble_destructor (fnname);
} }
#ifdef ASM_OUTPUT_SECTION_NAME #if defined (ASM_OUTPUT_SECTION_NAME) && defined (ASM_OUTPUT_CONSTRUCTOR)
/* If we're using init priority we can't use assemble_*tor, but on ELF /* If we're using init priority we can't use assemble_*tor, but on ELF
targets we can stick the references into named sections for GNU ld targets we can stick the references into named sections for GNU ld
to collect. */ to collect. */
......
...@@ -330,13 +330,15 @@ make_friend_class (type, friend_type) ...@@ -330,13 +330,15 @@ make_friend_class (type, friend_type)
pointed to by `this'. */ pointed to by `this'. */
tree tree
do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) do_friend (ctype, declarator, decl, parmdecls, attrlist,
tree ctype, declarator, decl, parmdecls; flags, quals, funcdef_flag)
tree ctype, declarator, decl, parmdecls, attrlist;
enum overload_flags flags; enum overload_flags flags;
tree quals; tree quals;
int funcdef_flag; int funcdef_flag;
{ {
int is_friend_template = 0; int is_friend_template = 0;
tree prefix_attributes, attributes;
/* Every decl that gets here is a friend of something. */ /* Every decl that gets here is a friend of something. */
DECL_FRIEND_P (decl) = 1; DECL_FRIEND_P (decl) = 1;
...@@ -350,8 +352,10 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) ...@@ -350,8 +352,10 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
declarator = DECL_NAME (get_first_fn (declarator)); declarator = DECL_NAME (get_first_fn (declarator));
} }
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) != FUNCTION_DECL)
is_friend_template = PROCESSING_REAL_TEMPLATE_DECL_P (); my_friendly_abort (990513);
is_friend_template = PROCESSING_REAL_TEMPLATE_DECL_P ();
if (ctype) if (ctype)
{ {
...@@ -360,53 +364,35 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) ...@@ -360,53 +364,35 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
cname = DECL_NAME (cname); cname = DECL_NAME (cname);
/* A method friend. */ /* A method friend. */
if (TREE_CODE (decl) == FUNCTION_DECL) if (flags == NO_SPECIAL && ctype && declarator == cname)
DECL_CONSTRUCTOR_P (decl) = 1;
/* This will set up DECL_ARGUMENTS for us. */
grokclassfn (ctype, decl, flags, quals);
if (is_friend_template)
decl = DECL_TI_TEMPLATE (push_template_decl (decl));
else if (template_class_depth (current_class_type))
decl = push_template_decl_real (decl, /*is_friend=*/1);
/* We can't do lookup in a type that involves template
parameters. Instead, we rely on tsubst_friend_function
to check the validity of the declaration later. */
if (uses_template_parms (ctype))
add_friend (current_class_type, decl);
/* A nested class may declare a member of an enclosing class
to be a friend, so we do lookup here even if CTYPE is in
the process of being defined. */
else if (TYPE_SIZE (ctype) != 0 || TYPE_BEING_DEFINED (ctype))
{ {
if (flags == NO_SPECIAL && ctype && declarator == cname) decl = check_classfn (ctype, decl);
DECL_CONSTRUCTOR_P (decl) = 1;
/* This will set up DECL_ARGUMENTS for us. */
grokclassfn (ctype, decl, flags, quals);
if (is_friend_template)
decl = DECL_TI_TEMPLATE (push_template_decl (decl));
else if (template_class_depth (current_class_type))
decl = push_template_decl_real (decl, /*is_friend=*/1);
/* We can't do lookup in a type that involves template if (decl)
parameters. Instead, we rely on tsubst_friend_function
to check the validity of the declaration later. */
if (uses_template_parms (ctype))
add_friend (current_class_type, decl); add_friend (current_class_type, decl);
/* A nested class may declare a member of an enclosing class
to be a friend, so we do lookup here even if CTYPE is in
the process of being defined. */
else if (TYPE_SIZE (ctype) != 0 || TYPE_BEING_DEFINED (ctype))
{
decl = check_classfn (ctype, decl);
if (decl)
add_friend (current_class_type, decl);
}
else
cp_error ("member `%D' declared as friend before type `%T' defined",
decl, ctype);
} }
else else
{ cp_error ("member `%D' declared as friend before type `%T' defined",
/* Possibly a bunch of method friends. */ decl, ctype);
/* Get the class they belong to. */
tree ctype = IDENTIFIER_TYPE_VALUE (cname);
tree fields = lookup_fnfields (TYPE_BINFO (ctype), declarator, 0);
if (fields)
add_friends (current_class_type, declarator, ctype);
else
cp_error ("method `%D' is not a member of class `%T'",
declarator, ctype);
decl = void_type_node;
}
} }
/* A global friend. /* A global friend.
@@ or possibly a friend from a base class ?!? */ @@ or possibly a friend from a base class ?!? */
...@@ -459,32 +445,28 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag) ...@@ -459,32 +445,28 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
is_friend_template ? DECL_TI_TEMPLATE (decl) : decl); is_friend_template ? DECL_TI_TEMPLATE (decl) : decl);
DECL_FRIEND_P (decl) = 1; DECL_FRIEND_P (decl) = 1;
} }
/* Unfortunately, we have to handle attributes here. Normally we would
handle them in start_decl_1, but since this is a friend decl start_decl_1
never gets to see it. */
if (attrlist)
{
attributes = TREE_PURPOSE (attrlist);
prefix_attributes = TREE_VALUE (attrlist);
}
else else
{ {
/* @@ Should be able to ingest later definitions of this function attributes = NULL_TREE;
before use. */ prefix_attributes = NULL_TREE;
tree decl = lookup_name_nonclass (declarator); }
if (decl == NULL_TREE)
{
cp_warning ("implicitly declaring `%T' as struct", declarator);
decl = xref_tag (record_type_node, declarator, 1);
decl = TYPE_MAIN_DECL (decl);
}
/* Allow abbreviated declarations of overloaded functions, #ifdef SET_DEFAULT_DECL_ATTRIBUTES
but not if those functions are really class names. */ SET_DEFAULT_DECL_ATTRIBUTES (decl, attributes);
if (TREE_CODE (decl) == TREE_LIST && TREE_TYPE (TREE_PURPOSE (decl))) #endif
{
cp_warning ("`friend %T' archaic, use `friend class %T' instead", /* Set attributes here so if duplicate decl, will have proper attributes. */
declarator, declarator); cplus_decl_attributes (decl, attributes, prefix_attributes);
decl = TREE_TYPE (TREE_PURPOSE (decl));
}
if (TREE_CODE (decl) == TREE_LIST)
add_friends (current_class_type, TREE_PURPOSE (decl), NULL_TREE);
else
make_friend_class (current_class_type, TREE_TYPE (decl));
decl = void_type_node;
}
return decl; return decl;
} }
...@@ -1893,6 +1893,7 @@ build_new (placement, decl, init, use_global_new) ...@@ -1893,6 +1893,7 @@ build_new (placement, decl, init, use_global_new)
tree type, rval; tree type, rval;
tree nelts = NULL_TREE, t; tree nelts = NULL_TREE, t;
int has_array = 0; int has_array = 0;
int momentary;
tree pending_sizes = NULL_TREE; tree pending_sizes = NULL_TREE;
...@@ -1952,6 +1953,9 @@ build_new (placement, decl, init, use_global_new) ...@@ -1952,6 +1953,9 @@ build_new (placement, decl, init, use_global_new)
== NULL_TREE) == NULL_TREE)
pedwarn ("size in array new must have integral type"); pedwarn ("size in array new must have integral type");
/* The size must live long so it can be used in a
cleanup. */
momentary = suspend_momentary ();
this_nelts = save_expr (cp_convert (sizetype, this_nelts)); this_nelts = save_expr (cp_convert (sizetype, this_nelts));
absdcl = TREE_OPERAND (absdcl, 0); absdcl = TREE_OPERAND (absdcl, 0);
if (this_nelts == integer_zero_node) if (this_nelts == integer_zero_node)
...@@ -1961,6 +1965,7 @@ build_new (placement, decl, init, use_global_new) ...@@ -1961,6 +1965,7 @@ build_new (placement, decl, init, use_global_new)
} }
else else
nelts = build_binary_op (MULT_EXPR, nelts, this_nelts); nelts = build_binary_op (MULT_EXPR, nelts, this_nelts);
resume_momentary (momentary);
} }
} }
else else
...@@ -2046,7 +2051,9 @@ build_new (placement, decl, init, use_global_new) ...@@ -2046,7 +2051,9 @@ build_new (placement, decl, init, use_global_new)
both new int and new int[10] return an int*. 5.3.4. */ both new int and new int[10] return an int*. 5.3.4. */
if (TREE_CODE (type) == ARRAY_TYPE && has_array == 0) if (TREE_CODE (type) == ARRAY_TYPE && has_array == 0)
{ {
momentary = suspend_momentary ();
nelts = array_type_nelts_top (type); nelts = array_type_nelts_top (type);
resume_momentary (momentary);
has_array = 1; has_array = 1;
type = TREE_TYPE (type); type = TREE_TYPE (type);
} }
...@@ -2429,9 +2436,6 @@ build_new_1 (exp) ...@@ -2429,9 +2436,6 @@ build_new_1 (exp)
fn = TREE_OPERAND (fn, 0); fn = TREE_OPERAND (fn, 0);
} }
/* Copy size to the saveable obstack. */
size = mapcar (size, permanent_p);
cleanup = build_op_delete_call (dcode, alloc_node, size, flags, fn); cleanup = build_op_delete_call (dcode, alloc_node, size, flags, fn);
resume_momentary (yes); resume_momentary (yes);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3123,7 +3123,7 @@ new_declarator: ...@@ -3123,7 +3123,7 @@ new_declarator:
/* ANSI direct-new-declarator (5.3.4) */ /* ANSI direct-new-declarator (5.3.4) */
direct_new_declarator: direct_new_declarator:
'[' expr ']' '[' nonmomentary_expr ']'
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
| direct_new_declarator '[' nonmomentary_expr ']' | direct_new_declarator '[' nonmomentary_expr ']'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); } { $$ = build_parse_node (ARRAY_REF, $$, $3); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment