diff options
author | Jason Merrill <jason@redhat.com> | 2003-03-17 23:10:45 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2003-03-17 23:10:45 -0500 |
commit | bdaa131bd0509fc849ea589e103c6339c45118e8 (patch) | |
tree | 6e3aaa141d1542f5a0f87593b7c67daea843b1d0 | |
parent | ffcfcb5fd9058825f8a4be55adbd70c0841b0d22 (diff) | |
download | gcc-bdaa131bd0509fc849ea589e103c6339c45118e8.zip gcc-bdaa131bd0509fc849ea589e103c6339c45118e8.tar.gz gcc-bdaa131bd0509fc849ea589e103c6339c45118e8.tar.bz2 |
re PR c++/10091 ([parisc] ICE in cp_expr_size, at cp/cp-lang.c:307)
PR c++/10091
* expr.c (expand_expr) [ADDR_EXPR]: Disallow taking the address of
an unaligned member of TREE_ADDRESSABLE type.
* cp/typeck.c (build_class_member_access_expr): Compare
TYPE_MAIN_VARIANTs.
From-SVN: r64520
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 5 | ||||
-rw-r--r-- | gcc/expr.c | 25 |
4 files changed, 32 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eaf0994..c2a1825 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-03-17 Jason Merrill <jason@redhat.com> + + PR c++/10091 + * expr.c (expand_expr) [ADDR_EXPR]: Disallow taking the address of + an unaligned member of TREE_ADDRESSABLE type. + 2003-03-18 Alan Modra <amodra@bigpond.net.au> * config/rs6000/linux64.h (MASK_PROFILE_KERNEL): Define. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2987491..d6efa61 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-03-17 Jason Merrill <jason@redhat.com> + + PR c++/10091 + * typeck.c (build_class_member_access_expr): Compare + TYPE_MAIN_VARIANTs. + 2003-03-17 Mark Mitchell <mark@codesourcery.com> PR c++/9639 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 0cbff77..142b128 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1941,7 +1941,8 @@ build_class_member_access_expr (tree object, tree member, && integer_zerop (TREE_OPERAND (object, 0))); /* Convert OBJECT to the type of MEMBER. */ - if (!same_type_p (object_type, member_scope)) + if (!same_type_p (TYPE_MAIN_VARIANT (object_type), + TYPE_MAIN_VARIANT (member_scope))) { tree binfo; base_kind kind; @@ -1951,7 +1952,7 @@ build_class_member_access_expr (tree object, tree member, if (binfo == error_mark_node) return error_mark_node; - /* It is invalid to use to try to get to a virtual base of a + /* It is invalid to try to get to a virtual base of a NULL object. The most common cause is invalid use of offsetof macro. */ if (null_object_p && kind == bk_via_virtual) @@ -9243,21 +9243,30 @@ expand_expr (exp, target, tmode, modifier) && MEM_ALIGN (op0) < BIGGEST_ALIGNMENT) { tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); - rtx new - = assign_stack_temp_for_type - (TYPE_MODE (inner_type), - MEM_SIZE (op0) ? INTVAL (MEM_SIZE (op0)) - : int_size_in_bytes (inner_type), - 1, build_qualified_type (inner_type, - (TYPE_QUALS (inner_type) - | TYPE_QUAL_CONST))); + rtx new; if (TYPE_ALIGN_OK (inner_type)) abort (); + if (TREE_ADDRESSABLE (inner_type)) + { + /* We can't make a bitwise copy of this object, so fail. */ + error ("cannot take the address of an unaligned member"); + return const0_rtx; + } + + new = assign_stack_temp_for_type + (TYPE_MODE (inner_type), + MEM_SIZE (op0) ? INTVAL (MEM_SIZE (op0)) + : int_size_in_bytes (inner_type), + 1, build_qualified_type (inner_type, + (TYPE_QUALS (inner_type) + | TYPE_QUAL_CONST))); + emit_block_move (new, op0, expr_size (TREE_OPERAND (exp, 0)), (modifier == EXPAND_STACK_PARM ? BLOCK_OP_CALL_PARM : BLOCK_OP_NORMAL)); + op0 = new; } |