diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-04-10 03:38:27 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-04-09 23:38:27 -0400 |
commit | dc26f4715d78c198d25994b3f97e2219c9cfade5 (patch) | |
tree | b5f953cac859b397058f9932dff3f71ebd03d28d /gcc | |
parent | 34a4c46602286492977989248419f834ee9f6ffc (diff) | |
download | gcc-dc26f4715d78c198d25994b3f97e2219c9cfade5.zip gcc-dc26f4715d78c198d25994b3f97e2219c9cfade5.tar.gz gcc-dc26f4715d78c198d25994b3f97e2219c9cfade5.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 5 | ||||
-rw-r--r-- | gcc/cp/sig.c | 1 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 5 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 89 |
6 files changed, 38 insertions, 80 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3db48c9..2a93633 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +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> * cp-tree.h (start_decl): Update prototype. diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index e4f802d..92dce8b 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -656,7 +656,11 @@ ocp_convert (type, expr, convtype, flags) if (TREE_READONLY_DECL_P (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. */; else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e))) /* Trivial conversion: cv-qualifiers do not matter on rvalues. */ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 9a9c2a5..a783fe5 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1808,7 +1808,10 @@ resolve_offset_ref (exp) tree basetype, addr; 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) { diff --git a/gcc/cp/sig.c b/gcc/cp/sig.c index c83c20a..f1e8ff9 100644 --- a/gcc/cp/sig.c +++ b/gcc/cp/sig.c @@ -880,7 +880,6 @@ build_signature_pointer_constructor (lhs, rhs) result = tree_cons (NULL_TREE, optr_expr, build_tree_list (NULL_TREE, sptr_expr)); result = build_nt (CONSTRUCTOR, NULL_TREE, result); - TREE_HAS_CONSTRUCTOR (result) = 1; result = digest_init (lhstype, result, 0); } else diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 9aac340..e13a312 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3062,8 +3062,6 @@ build_x_binary_op (code, arg1, arg2) enum tree_code code; tree arg1, arg2; { - tree rval; - if (processing_template_decl) return build_min_nt (code, arg1, arg2); @@ -4565,7 +4563,8 @@ build_unary_op (code, xarg, noconvert) /* Allow the address of a constructor if all the elements 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 is an error. */ diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3bfe54e..c135537 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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. */ /* Digest the specified initializer into an expression. */ @@ -763,24 +759,9 @@ digest_init (type, init, tail) if (TREE_CODE (init) == NON_LVALUE_EXPR) 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; - if (init && raw_constructor + if (raw_constructor && CONSTRUCTOR_ELTS (init) != 0 && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0) { @@ -792,41 +773,6 @@ digest_init (type, init, tail) 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 optionally enclosed in braces. */ @@ -858,11 +804,6 @@ digest_init (type, init, tail) 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; if (TYPE_DOMAIN (type) != 0 && TREE_CONSTANT (TYPE_SIZE (type))) @@ -887,6 +828,7 @@ digest_init (type, init, tail) if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == REFERENCE_TYPE || code == BOOLEAN_TYPE || code == COMPLEX_TYPE + || TYPE_PTRMEMFUNC_P (type) || (code == RECORD_TYPE && ! raw_constructor && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))) { @@ -899,9 +841,7 @@ digest_init (type, init, tail) } init = element; } - while (TREE_CODE (init) == CONSTRUCTOR - && ! (TREE_TYPE (init) - && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))) + while (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init)) { cp_pedwarn ("braces around scalar initializer for `%T'", type); init = CONSTRUCTOR_ELTS (init); @@ -933,15 +873,9 @@ digest_init (type, init, tail) } else if (raw_constructor) return process_init_constructor (type, init, (tree *)0); - else if (TYPE_NON_AGGREGATE_CLASS (type)) - { - int flags = LOOKUP_NORMAL; - /* Initialization from { } is copy-initialization. */ - if (tail) - flags |= LOOKUP_ONLYCONVERTING; - return convert_for_initialization (0, type, init, flags, - "initialization", NULL_TREE, 0); - } + else if (can_convert_arg (type, TREE_TYPE (init), init) + || TYPE_NON_AGGREGATE_CLASS (type)) + /* These are never initialized from multiple constructor elements. */; else if (tail != 0) { *tail = old_tail_contents; @@ -949,8 +883,15 @@ digest_init (type, init, tail) } 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"); |