diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-18 04:10:45 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-18 04:10:45 +0000 |
commit | dbdac1869526db03e101305cb26636e4afb382e3 (patch) | |
tree | 6e3aaa141d1542f5a0f87593b7c67daea843b1d0 /gcc/expr.c | |
parent | 3c6669f7c86e13b29f9bd7583a1af4ca65b7263c (diff) | |
download | gcc-dbdac1869526db03e101305cb26636e4afb382e3.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64520 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/gcc/expr.c b/gcc/expr.c index 04479da9443..926a18eb073 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -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; } |