OSDN Git Service

PR c++/27292
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Apr 2006 02:40:58 +0000 (02:40 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Apr 2006 02:40:58 +0000 (02:40 +0000)
* tree.c (rvalue): Convert bitfields to their declared types.
PR c++/27292
* g++.dg/conversion/bitfield4.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113339 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/bitfield4.C [new file with mode: 0644]

index aece2e8..17e3b29 100644 (file)
@@ -1,5 +1,8 @@
 2006-04-27  Mark Mitchell  <mark@codesourcery.com>
 
 2006-04-27  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/27292
+       * tree.c (rvalue): Convert bitfields to their declared types.
+
        PR c++/27102
        * typeck2.c (cxx_incomplete_type_diagnostic): Handle
        TYPENAME_TYPE.
        PR c++/27102
        * typeck2.c (cxx_incomplete_type_diagnostic): Handle
        TYPENAME_TYPE.
index a956205..60ba13f 100644 (file)
@@ -372,8 +372,9 @@ rvalue (tree expr)
   if (real_lvalue_p (expr))
     {
       type = is_bitfield_expr_with_lowered_type (expr);
   if (real_lvalue_p (expr))
     {
       type = is_bitfield_expr_with_lowered_type (expr);
-      if (!type)
-       type = TREE_TYPE (expr);
+      if (type)
+       return cp_convert (TYPE_MAIN_VARIANT (type), expr);
+      type = TREE_TYPE (expr);
       /* [basic.lval]
         
          Non-class rvalues always have cv-unqualified types.  */
       /* [basic.lval]
         
          Non-class rvalues always have cv-unqualified types.  */
index 5ae38b0..c8fc07c 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/27292
+       * g++.dg/conversion/bitfield4.C: New test.
+
 2006-04-27  Eric Christopher  <echristo@apple.com>
 
        * gcc.dg/pragma-ms_struct.c: New.
 2006-04-27  Eric Christopher  <echristo@apple.com>
 
        * gcc.dg/pragma-ms_struct.c: New.
diff --git a/gcc/testsuite/g++.dg/conversion/bitfield4.C b/gcc/testsuite/g++.dg/conversion/bitfield4.C
new file mode 100644 (file)
index 0000000..75fe301
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/27292
+
+enum ColorRole
+{
+  WindowText, Button
+};
+
+struct QPalette {
+
+ColorRole bg_role:8;
+
+ bool hasBackground();
+};
+
+
+bool
+QPalette::hasBackground ()
+{
+  return (ColorRole (bg_role) != WindowText);
+}