mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-09 02:56:44 +08:00
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
This commit is contained in:
parent
88b117b740
commit
7a8f9fa9cf
@ -1,3 +1,21 @@
|
||||
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>
|
||||
|
||||
* 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>
|
||||
* cp-tree.h (lang_decl_flags): Remove returns_first_arg and
|
||||
preserves_first_arg. Enlarge dummy accordingly.
|
||||
(DECL_TINFO_FN_P): New macro.
|
||||
(SET_DECL_TINO_FN_P): Likeiwse.
|
||||
(SET_DECL_TINFO_FN_P): Likeiwse.
|
||||
(DECL_RETURNS_FIRST_ARG): Remove.
|
||||
(DECL_PRESERVES_THIS): Likewise.
|
||||
(DECL_INIT_PRIORITY): New macro.
|
||||
|
@ -3016,7 +3016,7 @@ extern int is_friend PROTO((tree, tree));
|
||||
extern void make_friend_class PROTO((tree, tree));
|
||||
extern void add_friend PROTO((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 */
|
||||
extern void init_init_processing PROTO((void));
|
||||
|
@ -161,7 +161,7 @@ static void warn_extern_redeclared_static PROTO((tree, tree));
|
||||
static void grok_reference_init PROTO((tree, tree, tree));
|
||||
static tree grokfndecl PROTO((tree, tree, tree, tree, int,
|
||||
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 lookup_tag PROTO((enum tree_code, tree,
|
||||
struct binding_level *, int));
|
||||
@ -8697,14 +8697,14 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
|
||||
|
||||
static tree
|
||||
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)
|
||||
tree ctype, type;
|
||||
tree declarator;
|
||||
tree orig_declarator;
|
||||
int virtualp;
|
||||
enum overload_flags flags;
|
||||
tree quals, raises, attrlist;
|
||||
tree quals, raises;
|
||||
int check, friendp, publicp, inlinep, funcdef_flag, template_count;
|
||||
tree in_namespace;
|
||||
{
|
||||
@ -8868,10 +8868,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
|
||||
tentative. error_mark_node is replaced later with the BLOCK. */
|
||||
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. */
|
||||
if (check < 0)
|
||||
return decl;
|
||||
@ -8964,8 +8960,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
|
||||
if (ctype == NULL_TREE || check)
|
||||
return decl;
|
||||
|
||||
make_decl_rtl (decl, NULL_PTR, 1);
|
||||
|
||||
if (virtualp)
|
||||
{
|
||||
DECL_VIRTUAL_P (decl) = 1;
|
||||
@ -11306,7 +11300,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
||||
TREE_CODE (declarator) != TEMPLATE_ID_EXPR
|
||||
? declarator : dname,
|
||||
declarator,
|
||||
virtualp, flags, quals, raises, attrlist,
|
||||
virtualp, flags, quals, raises,
|
||||
friendp ? -1 : 0, friendp, publicp, inlinep,
|
||||
funcdef_flag, template_count, in_namespace);
|
||||
if (decl == NULL_TREE)
|
||||
@ -11356,7 +11350,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
||||
/* All method decls are public, so tell grokfndecl to set
|
||||
TREE_PUBLIC, also. */
|
||||
decl = grokfndecl (ctype, type, declarator, declarator,
|
||||
virtualp, flags, quals, raises, attrlist,
|
||||
virtualp, flags, quals, raises,
|
||||
friendp ? -1 : 0, friendp, 1, 0, funcdef_flag,
|
||||
template_count, in_namespace);
|
||||
if (decl == NULL_TREE)
|
||||
@ -11416,7 +11410,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
||||
}
|
||||
|
||||
t = do_friend (ctype, declarator, decl,
|
||||
last_function_parms, flags, quals,
|
||||
last_function_parms, attrlist, flags, quals,
|
||||
funcdef_flag);
|
||||
}
|
||||
if (t && funcdef_flag)
|
||||
@ -11549,7 +11543,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
||||
|| !RIDBIT_SETP (RID_STATIC, specbits));
|
||||
|
||||
decl = grokfndecl (ctype, type, original_name, declarator,
|
||||
virtualp, flags, quals, raises, attrlist,
|
||||
virtualp, flags, quals, raises,
|
||||
1, friendp,
|
||||
publicp, inlinep, funcdef_flag,
|
||||
template_count, in_namespace);
|
||||
|
@ -2950,7 +2950,7 @@ finish_objects (method_type, initp)
|
||||
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
|
||||
targets we can stick the references into named sections for GNU ld
|
||||
to collect. */
|
||||
|
120
gcc/cp/friend.c
120
gcc/cp/friend.c
@ -330,13 +330,15 @@ make_friend_class (type, friend_type)
|
||||
pointed to by `this'. */
|
||||
|
||||
tree
|
||||
do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
|
||||
tree ctype, declarator, decl, parmdecls;
|
||||
do_friend (ctype, declarator, decl, parmdecls, attrlist,
|
||||
flags, quals, funcdef_flag)
|
||||
tree ctype, declarator, decl, parmdecls, attrlist;
|
||||
enum overload_flags flags;
|
||||
tree quals;
|
||||
int funcdef_flag;
|
||||
{
|
||||
int is_friend_template = 0;
|
||||
tree prefix_attributes, attributes;
|
||||
|
||||
/* Every decl that gets here is a friend of something. */
|
||||
DECL_FRIEND_P (decl) = 1;
|
||||
@ -350,8 +352,10 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
|
||||
declarator = DECL_NAME (get_first_fn (declarator));
|
||||
}
|
||||
|
||||
if (TREE_CODE (decl) == FUNCTION_DECL)
|
||||
is_friend_template = PROCESSING_REAL_TEMPLATE_DECL_P ();
|
||||
if (TREE_CODE (decl) != FUNCTION_DECL)
|
||||
my_friendly_abort (990513);
|
||||
|
||||
is_friend_template = PROCESSING_REAL_TEMPLATE_DECL_P ();
|
||||
|
||||
if (ctype)
|
||||
{
|
||||
@ -360,53 +364,35 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
|
||||
cname = DECL_NAME (cname);
|
||||
|
||||
/* 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_CONSTRUCTOR_P (decl) = 1;
|
||||
decl = check_classfn (ctype, decl);
|
||||
|
||||
/* 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))
|
||||
if (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
|
||||
{
|
||||
/* Possibly a bunch of method friends. */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
cp_error ("member `%D' declared as friend before type `%T' defined",
|
||||
decl, ctype);
|
||||
}
|
||||
/* A global friend.
|
||||
@@ or possibly a friend from a base class ?!? */
|
||||
@ -459,32 +445,28 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
|
||||
is_friend_template ? DECL_TI_TEMPLATE (decl) : decl);
|
||||
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
|
||||
{
|
||||
/* @@ Should be able to ingest later definitions of this function
|
||||
before use. */
|
||||
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);
|
||||
}
|
||||
attributes = NULL_TREE;
|
||||
prefix_attributes = NULL_TREE;
|
||||
}
|
||||
|
||||
/* Allow abbreviated declarations of overloaded functions,
|
||||
but not if those functions are really class names. */
|
||||
if (TREE_CODE (decl) == TREE_LIST && TREE_TYPE (TREE_PURPOSE (decl)))
|
||||
{
|
||||
cp_warning ("`friend %T' archaic, use `friend class %T' instead",
|
||||
declarator, declarator);
|
||||
decl = TREE_TYPE (TREE_PURPOSE (decl));
|
||||
}
|
||||
#ifdef SET_DEFAULT_DECL_ATTRIBUTES
|
||||
SET_DEFAULT_DECL_ATTRIBUTES (decl, attributes);
|
||||
#endif
|
||||
|
||||
/* Set attributes here so if duplicate decl, will have proper attributes. */
|
||||
cplus_decl_attributes (decl, attributes, prefix_attributes);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1893,6 +1893,7 @@ build_new (placement, decl, init, use_global_new)
|
||||
tree type, rval;
|
||||
tree nelts = NULL_TREE, t;
|
||||
int has_array = 0;
|
||||
int momentary;
|
||||
|
||||
tree pending_sizes = NULL_TREE;
|
||||
|
||||
@ -1952,6 +1953,9 @@ build_new (placement, decl, init, use_global_new)
|
||||
== NULL_TREE)
|
||||
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));
|
||||
absdcl = TREE_OPERAND (absdcl, 0);
|
||||
if (this_nelts == integer_zero_node)
|
||||
@ -1961,6 +1965,7 @@ build_new (placement, decl, init, use_global_new)
|
||||
}
|
||||
else
|
||||
nelts = build_binary_op (MULT_EXPR, nelts, this_nelts);
|
||||
resume_momentary (momentary);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -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. */
|
||||
if (TREE_CODE (type) == ARRAY_TYPE && has_array == 0)
|
||||
{
|
||||
momentary = suspend_momentary ();
|
||||
nelts = array_type_nelts_top (type);
|
||||
resume_momentary (momentary);
|
||||
has_array = 1;
|
||||
type = TREE_TYPE (type);
|
||||
}
|
||||
@ -2429,9 +2436,6 @@ build_new_1 (exp)
|
||||
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);
|
||||
|
||||
resume_momentary (yes);
|
||||
|
1484
gcc/cp/parse.c
1484
gcc/cp/parse.c
File diff suppressed because it is too large
Load Diff
@ -3123,7 +3123,7 @@ new_declarator:
|
||||
|
||||
/* ANSI direct-new-declarator (5.3.4) */
|
||||
direct_new_declarator:
|
||||
'[' expr ']'
|
||||
'[' nonmomentary_expr ']'
|
||||
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
|
||||
| direct_new_declarator '[' nonmomentary_expr ']'
|
||||
{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
|
||||
|
Loading…
Reference in New Issue
Block a user