Commit 63718c49 by Gerald Baumgartner Committed by Mike Stump

some changes from gb.

From-SVN: r7615
parent 3cf2715d
Tue Jun 28 11:58:38 1994 Gerald Baumgartner (gb@cs.purdue.edu)
* class.c (finish_struct): Don't `cons_up_default_function's
for signatures.
(finish_struct): Handle an empty method_vec correctly.
* decl.c (grokdeclarator): Don't warn about a signature being
empty in a signature pointer declaration if we only saw a
forward declaration of the signature. Changed `warning's into
`cp_warning's.
* sig.c (build_sigtable): Don't die if a null signature table
constructor is returned.
(build_signature_pointer_constructor): If the signature table
constructor is null, the _sptr field is set to a null pointer
and cast to the appropriate type. Make copies of all null
pointers so that the type null_pointer_node doesn't get changed.
(build_signature_table_constructor): Added comments.
* sig.c (build_signature_pointer_constructor): Complain if we
try to assign to/initialize a signature pointer/reference of
an undefined signature.
Mon Jun 27 14:05:16 1994 Gerald Baumgartner (gb@cs.purdue.edu)
* typeck2.c (store_init_value): Don't be pedantic about
non-constant initializers of signature tables/pointers/references.
Fri Jun 24 16:49:41 1994 Gerald Baumgartner (gb@cs.purdue.edu)
* decl.c (grokdeclarator): If we are grokking an opaque typedef
in a signature, don't complain about it begin static.
Wed Jun 29 16:44:45 1994 Mike Stump (mrs@cygnus.com) Wed Jun 29 16:44:45 1994 Mike Stump (mrs@cygnus.com)
Fixes a problem of the this pointer being wrong in virtual calls to Fixes a problem of the this pointer being wrong in virtual calls to
......
...@@ -3270,7 +3270,8 @@ finish_struct (t, list_of_fieldlists, warn_anon) ...@@ -3270,7 +3270,8 @@ finish_struct (t, list_of_fieldlists, warn_anon)
only if no constructor has been declared for class X. So we only if no constructor has been declared for class X. So we
check TYPE_HAS_CONSTRUCTOR also, to make sure we don't generate check TYPE_HAS_CONSTRUCTOR also, to make sure we don't generate
one if they declared a constructor in this class. */ one if they declared a constructor in this class. */
if (! TYPE_HAS_CONSTRUCTOR (t) && ! cant_have_default_ctor) if (! TYPE_HAS_CONSTRUCTOR (t) && ! cant_have_default_ctor
&& ! IS_SIGNATURE (t))
{ {
tree default_fn = cons_up_default_function (t, name, fields, 2); tree default_fn = cons_up_default_function (t, name, fields, 2);
TREE_CHAIN (default_fn) = fn_fields; TREE_CHAIN (default_fn) = fn_fields;
...@@ -3278,7 +3279,8 @@ finish_struct (t, list_of_fieldlists, warn_anon) ...@@ -3278,7 +3279,8 @@ finish_struct (t, list_of_fieldlists, warn_anon)
} }
/* Create default copy constructor, if needed. */ /* Create default copy constructor, if needed. */
if (! TYPE_HAS_INIT_REF (t) && ! cant_synth_copy_ctor) if (! TYPE_HAS_INIT_REF (t) && ! cant_synth_copy_ctor
&& ! IS_SIGNATURE (t))
{ {
/* ARM 12.18: You get either X(X&) or X(const X&), but /* ARM 12.18: You get either X(X&) or X(const X&), but
not both. --Chip */ not both. --Chip */
...@@ -3295,7 +3297,8 @@ finish_struct (t, list_of_fieldlists, warn_anon) ...@@ -3295,7 +3297,8 @@ finish_struct (t, list_of_fieldlists, warn_anon)
|= (TYPE_HAS_ASSIGN_REF (t) || TYPE_USES_VIRTUAL_BASECLASSES (t) |= (TYPE_HAS_ASSIGN_REF (t) || TYPE_USES_VIRTUAL_BASECLASSES (t)
|| has_virtual || first_vfn_base_index >= 0); || has_virtual || first_vfn_base_index >= 0);
if (! TYPE_HAS_ASSIGN_REF (t) && ! cant_synth_asn_ref) if (! TYPE_HAS_ASSIGN_REF (t) && ! cant_synth_asn_ref
&& ! IS_SIGNATURE (t))
{ {
tree default_fn = tree default_fn =
cons_up_default_function (t, name, fields, cons_up_default_function (t, name, fields,
...@@ -3341,7 +3344,7 @@ finish_struct (t, list_of_fieldlists, warn_anon) ...@@ -3341,7 +3344,7 @@ finish_struct (t, list_of_fieldlists, warn_anon)
} }
{ {
int n_methods = TREE_VEC_LENGTH (method_vec); int n_methods = method_vec ? TREE_VEC_LENGTH (method_vec) : 0;
for (access_decls = nreverse (access_decls); access_decls; for (access_decls = nreverse (access_decls); access_decls;
access_decls = TREE_CHAIN (access_decls)) access_decls = TREE_CHAIN (access_decls))
......
...@@ -7742,7 +7742,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises) ...@@ -7742,7 +7742,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
return loc_typedecl; return loc_typedecl;
} }
else if (decl_context == FIELD else if (decl_context == FIELD
&& (! IS_SIGNATURE (current_class_type)) && (! IS_SIGNATURE (current_class_type)
|| SIGNATURE_GROKKING_TYPEDEF (current_class_type))
/* C++ allows static class elements */ /* C++ allows static class elements */
&& RIDBIT_SETP (RID_STATIC, specbits)) && RIDBIT_SETP (RID_STATIC, specbits))
/* C++ also allows inlines and signed and unsigned elements, /* C++ also allows inlines and signed and unsigned elements,
...@@ -8238,9 +8239,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises) ...@@ -8238,9 +8239,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
{ {
if (TREE_CODE (declarator) == ADDR_EXPR) if (TREE_CODE (declarator) == ADDR_EXPR)
{ {
if (CLASSTYPE_METHOD_VEC (type) == NULL_TREE) if (CLASSTYPE_METHOD_VEC (type) == NULL_TREE
warning ("empty signature `%s' used in signature reference declaration", && TYPE_SIZE (type))
TYPE_NAME_STRING(type)); cp_warning ("empty signature `%T' used in signature reference declaration",
type);
#if 0 #if 0
type = build_signature_reference_type (type, type = build_signature_reference_type (type,
constp, volatilep); constp, volatilep);
...@@ -8251,9 +8253,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises) ...@@ -8251,9 +8253,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
} }
else else
{ {
if (CLASSTYPE_METHOD_VEC (type) == NULL_TREE) if (CLASSTYPE_METHOD_VEC (type) == NULL_TREE
warning ("empty signature `%s' used in signature pointer declaration", && TYPE_SIZE (type))
TYPE_NAME_STRING(type)); cp_warning ("empty signature `%T' used in signature pointer declaration",
type);
type = build_signature_pointer_type (type, type = build_signature_pointer_type (type,
constp, volatilep); constp, volatilep);
} }
......
...@@ -610,6 +610,7 @@ build_signature_table_constructor (sig_ty, rhs) ...@@ -610,6 +610,7 @@ build_signature_table_constructor (sig_ty, rhs)
if (result == NULL_TREE) if (result == NULL_TREE)
{ {
/* The signature was empty, we don't need a signature table. */
undo_casts (sig_ty); undo_casts (sig_ty);
return NULL_TREE; return NULL_TREE;
} }
...@@ -618,17 +619,20 @@ build_signature_table_constructor (sig_ty, rhs) ...@@ -618,17 +619,20 @@ build_signature_table_constructor (sig_ty, rhs)
{ {
if (first_rhs_field == TYPE_FIELDS (rhstype)) if (first_rhs_field == TYPE_FIELDS (rhstype))
{ {
/* The sptr field on the lhs can be copied from the rhs. */
undo_casts (sig_ty); undo_casts (sig_ty);
return integer_zero_node; return integer_zero_node;
} }
else else
{ {
/* The sptr field on the lhs will point into the rhs sigtable. */
undo_casts (sig_ty); undo_casts (sig_ty);
return build_component_ref (rhs, DECL_NAME (first_rhs_field), return build_component_ref (rhs, DECL_NAME (first_rhs_field),
NULL_TREE, 0); NULL_TREE, 0);
} }
} }
/* We need to construct a new signature table. */
result = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (result)); result = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (result));
TREE_HAS_CONSTRUCTOR (result) = 1; TREE_HAS_CONSTRUCTOR (result) = 1;
TREE_CONSTANT (result) = !sig_ptr_p; TREE_CONSTANT (result) = !sig_ptr_p;
...@@ -679,7 +683,7 @@ build_sigtable (sig_type, rhs_type, init_from) ...@@ -679,7 +683,7 @@ build_sigtable (sig_type, rhs_type, init_from)
SIGTABLE_HAS_BEEN_GENERATED (sig_type) = 1; SIGTABLE_HAS_BEEN_GENERATED (sig_type) = 1;
init_expr = build_signature_table_constructor (sig_type, init_from); init_expr = build_signature_table_constructor (sig_type, init_from);
if (TREE_CODE (init_expr) != CONSTRUCTOR) if (init_expr == NULL_TREE || TREE_CODE (init_expr) != CONSTRUCTOR)
return init_expr; return init_expr;
if (name == NULL_TREE) if (name == NULL_TREE)
...@@ -748,6 +752,14 @@ build_signature_pointer_constructor (lhs, rhs) ...@@ -748,6 +752,14 @@ build_signature_pointer_constructor (lhs, rhs)
return error_mark_node; return error_mark_node;
} }
if (TYPE_SIZE (sig_ty) == NULL_TREE)
{
cp_error ("undefined signature `%T' used in signature %s declaration",
sig_ty,
IS_SIGNATURE_POINTER (lhstype) ? "pointer" : "reference");
return error_mark_node;
}
/* If SIG_TY is permanent, make the signature table constructor and /* If SIG_TY is permanent, make the signature table constructor and
the signature pointer/reference constructor permanent too. */ the signature pointer/reference constructor permanent too. */
if (TREE_PERMANENT (sig_ty)) if (TREE_PERMANENT (sig_ty))
...@@ -779,7 +791,11 @@ build_signature_pointer_constructor (lhs, rhs) ...@@ -779,7 +791,11 @@ build_signature_pointer_constructor (lhs, rhs)
return error_mark_node; return error_mark_node;
optr_expr = build_optr_ref (rhs); optr_expr = build_optr_ref (rhs);
if (sig_tbl == integer_zero_node) if (sig_tbl == NULL_TREE)
/* The signature was empty. The signature pointer is
pretty useless, but the user has been warned. */
sptr_expr = copy_node (null_pointer_node);
else if (sig_tbl == integer_zero_node)
sptr_expr = rhs_sptr_ref; sptr_expr = rhs_sptr_ref;
else else
sptr_expr = build_unary_op (ADDR_EXPR, sig_tbl, 0); sptr_expr = build_unary_op (ADDR_EXPR, sig_tbl, 0);
...@@ -802,6 +818,14 @@ build_signature_pointer_constructor (lhs, rhs) ...@@ -802,6 +818,14 @@ build_signature_pointer_constructor (lhs, rhs)
return error_mark_node; return error_mark_node;
optr_expr = rhs; optr_expr = rhs;
if (sig_tbl == NULL_TREE)
/* The signature was empty. The signature pointer is
pretty useless, but the user has been warned. */
{
sptr_expr = copy_node (null_pointer_node);
TREE_TYPE (sptr_expr) = build_pointer_type (sig_ty);
}
else
sptr_expr = build_unary_op (ADDR_EXPR, sig_tbl, 0); sptr_expr = build_unary_op (ADDR_EXPR, sig_tbl, 0);
if (CLASSTYPE_VFIELD (TREE_TYPE (rhstype))) if (CLASSTYPE_VFIELD (TREE_TYPE (rhstype)))
{ {
...@@ -810,7 +834,7 @@ build_signature_pointer_constructor (lhs, rhs) ...@@ -810,7 +834,7 @@ build_signature_pointer_constructor (lhs, rhs)
rhs_vptr, NULL_TREE, 0); rhs_vptr, NULL_TREE, 0);
} }
else else
vptr_expr = null_pointer_node; vptr_expr = copy_node (null_pointer_node);
TREE_TYPE (vptr_expr) = build_pointer_type (vtbl_type_node); TREE_TYPE (vptr_expr) = build_pointer_type (vtbl_type_node);
} }
......
...@@ -601,7 +601,13 @@ store_init_value (decl, init) ...@@ -601,7 +601,13 @@ store_init_value (decl, init)
return value; return value;
else else
{ {
if (pedantic && TREE_CODE (value) == CONSTRUCTOR) if (pedantic && TREE_CODE (value) == CONSTRUCTOR
/* Don't complain about non-constant initializers of
signature tables and signature pointers/references. */
&& ! (TYPE_LANG_SPECIFIC (type)
&& (IS_SIGNATURE (type)
|| IS_SIGNATURE_POINTER (type)
|| IS_SIGNATURE_REFERENCE (type))))
{ {
if (! TREE_CONSTANT (value) || ! TREE_STATIC (value)) if (! TREE_CONSTANT (value) || ! TREE_STATIC (value))
pedwarn ("ANSI C++ forbids non-constant aggregate initializer expressions"); pedwarn ("ANSI C++ forbids non-constant aggregate initializer expressions");
......
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