]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/27292 (ICE on casts on bitfields)
authorMark Mitchell <mark@codesourcery.com>
Fri, 28 Apr 2006 02:40:58 +0000 (02:40 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 28 Apr 2006 02:40:58 +0000 (02:40 +0000)
PR c++/27292
* tree.c (rvalue): Convert bitfields to their declared types.
PR c++/27292
* g++.dg/conversion/bitfield4.C: New test.

From-SVN: r113339

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

index aece2e85da0a2e94dd070bfa221d379c4417a52d..17e3b291c214d59dafb70218a67d1cb15f570a65 100644 (file)
@@ -1,5 +1,8 @@
 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.
index a956205a13603c407b176889cb5cc0fc0f7fdff0..60ba13f99369cfcec2de6686475752d71e130ea0 100644 (file)
@@ -372,8 +372,9 @@ rvalue (tree 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.  */
index 5ae38b0e7239796c22f2d1451bbcc52dc81b078b..c8fc07c479837a09a17f5e12616b48a20ef098de 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.
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);
+}
This page took 0.102152 seconds and 5 git commands to generate.