diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2002-08-08 15:59:33 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2002-08-08 15:59:33 +0000 |
commit | c93a26f5ea7f355b1421e820ac989a25d75306ce (patch) | |
tree | c6e3f6f93e3d034998db24b9f3f80fa7f866a0e4 | |
parent | aa2a83dc0c0614abfdeea82b0bd72e6924732022 (diff) | |
download | gcc-c93a26f5ea7f355b1421e820ac989a25d75306ce.zip gcc-c93a26f5ea7f355b1421e820ac989a25d75306ce.tar.gz gcc-c93a26f5ea7f355b1421e820ac989a25d75306ce.tar.bz2 |
typeck.c (build_component_addr): Remove.
cp:
* typeck.c (build_component_addr): Remove.
(build_unary_op): Just check it's not a bitfield, and then build
an ADDR_EXPR.
testsuite:
* g++.dg/other/packed1.C: New test.
From-SVN: r56132
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 54 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/packed1.C | 22 |
4 files changed, 39 insertions, 47 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3d852a1..361da75 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2002-08-08 Nathan Sidwell <nathan@codesourcery.com> + * typeck.c (build_component_addr): Remove. + (build_unary_op): Just check it's not a bitfield, and then build + an ADDR_EXPR. + +2002-08-08 Nathan Sidwell <nathan@codesourcery.com> + * class.c (convert_to_base): Correct check for error_mark_node. (create_vtable_ptr): Remove unused VFUNS_P parm. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6ac3822..97626f6 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -57,7 +57,6 @@ static int comp_array_types PARAMS ((int (*) (tree, tree, int), tree, static tree common_base_type PARAMS ((tree, tree)); static tree lookup_anon_field PARAMS ((tree, tree)); static tree pointer_diff PARAMS ((tree, tree, tree)); -static tree build_component_addr PARAMS ((tree, tree)); static tree qualify_type_recursive PARAMS ((tree, tree)); static tree get_delta_difference PARAMS ((tree, tree, int)); static int comp_cv_target_types PARAMS ((tree, tree, int)); @@ -3741,50 +3740,6 @@ pointer_diff (op0, op1, ptrtype) return folded; } -/* Handle the case of taking the address of a COMPONENT_REF. - Called by `build_unary_op'. - - ARG is the COMPONENT_REF whose address we want. - ARGTYPE is the pointer type that this address should have. */ - -static tree -build_component_addr (arg, argtype) - tree arg, argtype; -{ - tree field = TREE_OPERAND (arg, 1); - tree basetype = decl_type_context (field); - tree rval = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0); - - my_friendly_assert (TREE_CODE (field) == FIELD_DECL, 981018); - - if (DECL_C_BIT_FIELD (field)) - { - error ("attempt to take address of bit-field structure member `%D'", - field); - return error_mark_node; - } - - if (TREE_CODE (field) == FIELD_DECL - && TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype)) - { - /* Can't convert directly to ARGTYPE, since that - may have the same pointer type as one of our - baseclasses. */ - tree binfo = lookup_base (TREE_TYPE (TREE_TYPE (rval)), basetype, - ba_check, NULL); - - rval = build_base_path (PLUS_EXPR, rval, binfo, 1); - rval = build1 (NOP_EXPR, argtype, rval); - TREE_CONSTANT (rval) = TREE_CONSTANT (TREE_OPERAND (rval, 0)); - } - else - /* This conversion is harmless. */ - rval = convert_force (argtype, rval, 0); - - return fold (build (PLUS_EXPR, argtype, rval, - cp_convert (argtype, byte_position (field)))); -} - /* Construct and perhaps optimize a tree representation for a unary operation. CODE, a tree_code, specifies the operation and XARG is the operand. */ @@ -4290,8 +4245,13 @@ build_unary_op (code, xarg, noconvert) { tree addr; - if (TREE_CODE (arg) == COMPONENT_REF) - addr = build_component_addr (arg, argtype); + if (TREE_CODE (arg) == COMPONENT_REF + && DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1))) + { + error ("attempt to take address of bit-field structure member `%D'", + TREE_OPERAND (arg, 1)); + return error_mark_node; + } else addr = build1 (ADDR_EXPR, argtype, arg); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c458f43..fa5f8e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-08-08 Nathan Sidwell <nathan@codesourcery.com> + + * g++.dg/other/packed1.C: New test. + 2002-08-07 Mark Mitchell <mark@codesourcery.com> * g++.dg/abi/offsetof.C: Tweak error messages. diff --git a/gcc/testsuite/g++.dg/other/packed1.C b/gcc/testsuite/g++.dg/other/packed1.C new file mode 100644 index 0000000..b515854 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/packed1.C @@ -0,0 +1,22 @@ +// { dg-do run } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Aug 2002 <nathan@codesourcery.com> + +// WRS SPR 63496, lost packed attribute when accessing a packed +// field. This matters on aligned architectures like sh + +struct thing { int m; }; + +struct pod {char a; thing m __attribute__ ((packed)); }; + +int main () +{ + thing t; + pod p; + + p.m = t; /* runtime bus error here */ + + return 0; + +}; |