diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-23 01:50:45 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-23 01:50:45 +0000 |
commit | 4281aa504486f7c456b05a0826a12126c1462b27 (patch) | |
tree | 7fee3dd0f2bdbe38c84d900eae7e611ffd75e0e4 /gcc/cp | |
parent | f6c1128755318bcf0d94174e6185a7ccbddd83e5 (diff) | |
download | gcc-4281aa504486f7c456b05a0826a12126c1462b27.tar.gz |
gcc/cp/ChangeLog:
PR c++/33984
* call.c (reference_binding): For bitfields use the declared bitfield
type.
(add_builtin_candidates): Likewise.
* class.c (layout_class_type): For bitfields copy over the
original type quals.
gcc/testsuite/ChangeLog:
PR c++/33984
* g++.dg/conversion/bitfield7.C: New test.
* g++.dg/cpp0x/decltype4.C: Fixed xfail.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131751 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/call.c | 19 | ||||
-rw-r--r-- | gcc/cp/class.c | 14 |
3 files changed, 30 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 45297deda43..f9971d4943d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2008-01-22 Jakub Jelinek <jakub@redhat.com>, Alexandre Oliva <aoliva@redhat.com> + + PR c++/33984 + * call.c (reference_binding): For bitfields use the declared bitfield + type. + (add_builtin_candidates): Likewise. + * class.c (layout_class_type): For bitfields copy over the + original type quals. + 2008-01-22 Jason Merrill <jason@redhat.com> PR c++/34912 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f15550d7fda..1e591a61ac1 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1,6 +1,6 @@ /* Functions related to invoking methods and overloaded functions. Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) and modified by Brendan Kehoe (brendan@cygnus.com). @@ -1114,6 +1114,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) conversion *conv = NULL; tree to = TREE_TYPE (rto); tree from = rfrom; + tree tfrom; bool related_p; bool compatible_p; cp_lvalue_kind lvalue_p = clk_none; @@ -1135,16 +1136,20 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) else if (expr) lvalue_p = real_lvalue_p (expr); + tfrom = from; + if ((lvalue_p & clk_bitfield) != 0) + tfrom = unlowered_expr_type (expr); + /* Figure out whether or not the types are reference-related and reference compatible. We have do do this after stripping references from FROM. */ - related_p = reference_related_p (to, from); + related_p = reference_related_p (to, tfrom); /* If this is a C cast, first convert to an appropriately qualified type, so that we can later do a const_cast to the desired type. */ if (related_p && c_cast_p - && !at_least_as_qualified_p (to, from)) - to = build_qualified_type (to, cp_type_quals (from)); - compatible_p = reference_compatible_p (to, from); + && !at_least_as_qualified_p (to, tfrom)) + to = build_qualified_type (to, cp_type_quals (tfrom)); + compatible_p = reference_compatible_p (to, tfrom); /* Directly bind reference when target expression's type is compatible with the reference and expression is an lvalue. In DR391, the wording in @@ -1171,7 +1176,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) is bound to the object represented by the rvalue or to a sub-object within that object. */ - conv = build_identity_conv (from, expr); + conv = build_identity_conv (tfrom, expr); conv = direct_reference_binding (rto, conv); if (flags & LOOKUP_PREFER_RVALUE) @@ -2084,7 +2089,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, for (i = 0; i < 3; ++i) { if (args[i]) - argtypes[i] = lvalue_type (args[i]); + argtypes[i] = unlowered_expr_type (args[i]); else argtypes[i] = NULL_TREE; } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 6e67157a290..65e7144bfd7 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4795,14 +4795,18 @@ layout_class_type (tree t, tree *virtuals_p) must be converted to the type given the bitfield here. */ if (DECL_C_BIT_FIELD (field)) { - tree ftype; unsigned HOST_WIDE_INT width; - ftype = TREE_TYPE (field); + tree ftype = TREE_TYPE (field); width = tree_low_cst (DECL_SIZE (field), /*unsignedp=*/1); if (width != TYPE_PRECISION (ftype)) - TREE_TYPE (field) - = c_build_bitfield_integer_type (width, - TYPE_UNSIGNED (ftype)); + { + TREE_TYPE (field) + = c_build_bitfield_integer_type (width, + TYPE_UNSIGNED (ftype)); + TREE_TYPE (field) + = cp_build_qualified_type (TREE_TYPE (field), + TYPE_QUALS (ftype)); + } } /* If we needed additional padding after this field, add it |