Commit dc26f471 by Jason Merrill Committed by Jason Merrill

sig.c (build_signature_pointer_constructor): Don't set TREE_HAS_CONSTRUCTOR for…

sig.c (build_signature_pointer_constructor): Don't set TREE_HAS_CONSTRUCTOR for a signature pointer.

	* sig.c (build_signature_pointer_constructor): Don't set
	TREE_HAS_CONSTRUCTOR for a signature pointer.
	* cvt.c (ocp_convert): Don't force a temporary for internal structs.
	* init.c (resolve_offset_ref): Warn about implicit & on pmfs
	here, too.
	* typeck.c (build_unary_op): Only allow taking the address of a
	real constructor.
	* typeck2.c (digest_init): Simplify.
	(store_init_value): Don't pedwarn about using { } for pmfs.

From-SVN: r19079
parent 34a4c466
Thu Apr 9 02:40:48 1998 Jason Merrill <jason@yorick.cygnus.com>
* sig.c (build_signature_pointer_constructor): Don't set
TREE_HAS_CONSTRUCTOR for a signature pointer.
* cvt.c (ocp_convert): Don't force a temporary for internal structs.
* init.c (resolve_offset_ref): Warn about implicit & on pmfs
here, too.
* typeck.c (build_unary_op): Only allow taking the address of a
real constructor.
* typeck2.c (digest_init): Simplify.
(store_init_value): Don't pedwarn about using { } for pmfs.
Thu Apr 9 22:16:57 1998 Per Bothner <bothner@cygnus.com> Thu Apr 9 22:16:57 1998 Per Bothner <bothner@cygnus.com>
* cp-tree.h (start_decl): Update prototype. * cp-tree.h (start_decl): Update prototype.
......
...@@ -656,7 +656,11 @@ ocp_convert (type, expr, convtype, flags) ...@@ -656,7 +656,11 @@ ocp_convert (type, expr, convtype, flags)
if (TREE_READONLY_DECL_P (e)) if (TREE_READONLY_DECL_P (e))
e = decl_constant_value (e); e = decl_constant_value (e);
if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP)) if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP)
/* Some internal structures (vtable_entry_type, sigtbl_ptr_type)
don't go through finish_struct, so they don't have the synthesized
constructors. So don't force a temporary. */
&& TYPE_HAS_CONSTRUCTOR (type))
/* We need a new temporary; don't take this shortcut. */; /* We need a new temporary; don't take this shortcut. */;
else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e))) else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
/* Trivial conversion: cv-qualifiers do not matter on rvalues. */ /* Trivial conversion: cv-qualifiers do not matter on rvalues. */
......
...@@ -1808,7 +1808,10 @@ resolve_offset_ref (exp) ...@@ -1808,7 +1808,10 @@ resolve_offset_ref (exp)
tree basetype, addr; tree basetype, addr;
if (TREE_CODE (exp) == TREE_LIST) if (TREE_CODE (exp) == TREE_LIST)
return build_unary_op (ADDR_EXPR, exp, 0); {
cp_pedwarn ("assuming & on overloaded member function");
return build_unary_op (ADDR_EXPR, exp, 0);
}
if (TREE_CODE (exp) == OFFSET_REF) if (TREE_CODE (exp) == OFFSET_REF)
{ {
......
...@@ -880,7 +880,6 @@ build_signature_pointer_constructor (lhs, rhs) ...@@ -880,7 +880,6 @@ build_signature_pointer_constructor (lhs, rhs)
result = tree_cons (NULL_TREE, optr_expr, result = tree_cons (NULL_TREE, optr_expr,
build_tree_list (NULL_TREE, sptr_expr)); build_tree_list (NULL_TREE, sptr_expr));
result = build_nt (CONSTRUCTOR, NULL_TREE, result); result = build_nt (CONSTRUCTOR, NULL_TREE, result);
TREE_HAS_CONSTRUCTOR (result) = 1;
result = digest_init (lhstype, result, 0); result = digest_init (lhstype, result, 0);
} }
else else
......
...@@ -3062,8 +3062,6 @@ build_x_binary_op (code, arg1, arg2) ...@@ -3062,8 +3062,6 @@ build_x_binary_op (code, arg1, arg2)
enum tree_code code; enum tree_code code;
tree arg1, arg2; tree arg1, arg2;
{ {
tree rval;
if (processing_template_decl) if (processing_template_decl)
return build_min_nt (code, arg1, arg2); return build_min_nt (code, arg1, arg2);
...@@ -4565,7 +4563,8 @@ build_unary_op (code, xarg, noconvert) ...@@ -4565,7 +4563,8 @@ build_unary_op (code, xarg, noconvert)
/* Allow the address of a constructor if all the elements /* Allow the address of a constructor if all the elements
are constant. */ are constant. */
if (TREE_CODE (arg) == CONSTRUCTOR && TREE_CONSTANT (arg)) if (TREE_CODE (arg) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (arg)
&& TREE_CONSTANT (arg))
; ;
/* Anything not already handled and not a true memory reference /* Anything not already handled and not a true memory reference
is an error. */ is an error. */
......
...@@ -669,10 +669,6 @@ store_init_value (decl, init) ...@@ -669,10 +669,6 @@ store_init_value (decl, init)
} }
} }
if (TYPE_PTRMEMFUNC_P (type) && TREE_CODE (init) == CONSTRUCTOR
&& TREE_TYPE (init) == NULL_TREE)
cp_pedwarn ("initializer list for `%T'", type);
/* End of special C++ code. */ /* End of special C++ code. */
/* Digest the specified initializer into an expression. */ /* Digest the specified initializer into an expression. */
...@@ -763,24 +759,9 @@ digest_init (type, init, tail) ...@@ -763,24 +759,9 @@ digest_init (type, init, tail)
if (TREE_CODE (init) == NON_LVALUE_EXPR) if (TREE_CODE (init) == NON_LVALUE_EXPR)
init = TREE_OPERAND (init, 0); init = TREE_OPERAND (init, 0);
if (init && TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (type))
init = default_conversion (init);
if (init && TYPE_PTRMEMFUNC_P (type)
&& ((TREE_CODE (init) == ADDR_EXPR
&& ((TREE_CODE (TREE_TYPE (init)) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (TREE_TYPE (init))) == METHOD_TYPE)
|| TREE_CODE (TREE_OPERAND (init, 0)) == TREE_LIST))
|| TREE_CODE (init) == TREE_LIST
|| integer_zerop (init)
|| (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))))
{
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), init, 0);
}
raw_constructor = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0; raw_constructor = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0;
if (init && raw_constructor if (raw_constructor
&& CONSTRUCTOR_ELTS (init) != 0 && CONSTRUCTOR_ELTS (init) != 0
&& TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0) && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0)
{ {
...@@ -792,41 +773,6 @@ digest_init (type, init, tail) ...@@ -792,41 +773,6 @@ digest_init (type, init, tail)
return element; return element;
} }
/* Any type can be initialized from an expression of the same type,
optionally with braces. */
if (init && TREE_TYPE (init)
&& (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == type
|| (code == ARRAY_TYPE && comptypes (TREE_TYPE (init), type, 1))))
{
if (pedantic && code == ARRAY_TYPE
&& TREE_CODE (init) != STRING_CST)
pedwarn ("ANSI C++ forbids initializing array from array expression");
if (TREE_CODE (init) == CONST_DECL)
init = DECL_INITIAL (init);
else if (TREE_READONLY_DECL_P (init))
init = decl_constant_value (init);
else if (IS_AGGR_TYPE (type) && TYPE_NEEDS_CONSTRUCTING (type))
init = ocp_convert (type, init, CONV_IMPLICIT|CONV_FORCE_TEMP,
LOOKUP_NORMAL);
return init;
}
if (element && (TREE_TYPE (element) == type
|| (code == ARRAY_TYPE && TREE_TYPE (element)
&& comptypes (TREE_TYPE (element), type, 1))))
{
if (pedantic && code == ARRAY_TYPE)
pedwarn ("ANSI C++ forbids initializing array from array expression");
if (pedantic && (code == RECORD_TYPE || code == UNION_TYPE))
pedwarn ("ANSI C++ forbids single nonscalar initializer with braces");
if (TREE_CODE (element) == CONST_DECL)
element = DECL_INITIAL (element);
else if (TREE_READONLY_DECL_P (element))
element = decl_constant_value (element);
return element;
}
/* Initialization of an array of chars from a string constant /* Initialization of an array of chars from a string constant
optionally enclosed in braces. */ optionally enclosed in braces. */
...@@ -858,11 +804,6 @@ digest_init (type, init, tail) ...@@ -858,11 +804,6 @@ digest_init (type, init, tail)
return error_mark_node; return error_mark_node;
} }
if (pedantic
&& typ1 != char_type_node
&& typ1 != signed_char_type_node
&& typ1 != unsigned_char_type_node)
pedwarn ("ANSI C++ forbids string initializer except for `char' elements");
TREE_TYPE (string) = type; TREE_TYPE (string) = type;
if (TYPE_DOMAIN (type) != 0 if (TYPE_DOMAIN (type) != 0
&& TREE_CONSTANT (TYPE_SIZE (type))) && TREE_CONSTANT (TYPE_SIZE (type)))
...@@ -887,6 +828,7 @@ digest_init (type, init, tail) ...@@ -887,6 +828,7 @@ digest_init (type, init, tail)
if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
|| code == ENUMERAL_TYPE || code == REFERENCE_TYPE || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
|| code == BOOLEAN_TYPE || code == COMPLEX_TYPE || code == BOOLEAN_TYPE || code == COMPLEX_TYPE
|| TYPE_PTRMEMFUNC_P (type)
|| (code == RECORD_TYPE && ! raw_constructor || (code == RECORD_TYPE && ! raw_constructor
&& (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))) && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type))))
{ {
...@@ -899,9 +841,7 @@ digest_init (type, init, tail) ...@@ -899,9 +841,7 @@ digest_init (type, init, tail)
} }
init = element; init = element;
} }
while (TREE_CODE (init) == CONSTRUCTOR while (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init))
&& ! (TREE_TYPE (init)
&& TYPE_PTRMEMFUNC_P (TREE_TYPE (init))))
{ {
cp_pedwarn ("braces around scalar initializer for `%T'", type); cp_pedwarn ("braces around scalar initializer for `%T'", type);
init = CONSTRUCTOR_ELTS (init); init = CONSTRUCTOR_ELTS (init);
...@@ -933,15 +873,9 @@ digest_init (type, init, tail) ...@@ -933,15 +873,9 @@ digest_init (type, init, tail)
} }
else if (raw_constructor) else if (raw_constructor)
return process_init_constructor (type, init, (tree *)0); return process_init_constructor (type, init, (tree *)0);
else if (TYPE_NON_AGGREGATE_CLASS (type)) else if (can_convert_arg (type, TREE_TYPE (init), init)
{ || TYPE_NON_AGGREGATE_CLASS (type))
int flags = LOOKUP_NORMAL; /* These are never initialized from multiple constructor elements. */;
/* Initialization from { } is copy-initialization. */
if (tail)
flags |= LOOKUP_ONLYCONVERTING;
return convert_for_initialization (0, type, init, flags,
"initialization", NULL_TREE, 0);
}
else if (tail != 0) else if (tail != 0)
{ {
*tail = old_tail_contents; *tail = old_tail_contents;
...@@ -949,8 +883,15 @@ digest_init (type, init, tail) ...@@ -949,8 +883,15 @@ digest_init (type, init, tail)
} }
if (code != ARRAY_TYPE) if (code != ARRAY_TYPE)
return convert_for_initialization (NULL_TREE, type, init, LOOKUP_NORMAL, {
"initialization", NULL_TREE, 0); int flags = LOOKUP_NORMAL;
/* Initialization from { } is copy-initialization. */
if (tail)
flags |= LOOKUP_ONLYCONVERTING;
return convert_for_initialization (NULL_TREE, type, init, flags,
"initialization", NULL_TREE, 0);
}
} }
error ("invalid initializer"); error ("invalid initializer");
......
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