]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/35336 (Broken diagnostic: 'bit_field_ref' not supported by dump_expr)
authorJakub Jelinek <jakub@redhat.com>
Fri, 5 Dec 2008 21:10:16 +0000 (22:10 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 5 Dec 2008 21:10:16 +0000 (22:10 +0100)
PR c++/35336
* c-pretty-print.c (pp_c_postfix_expression): Handle BIT_FIELD_REF.
(pp_c_expression): Likewise.

* error.c (dump_expr): Handle BIT_FIELD_REF.

* g++.dg/other/error30.C: New test.

From-SVN: r142497

gcc/ChangeLog
gcc/c-pretty-print.c
gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/error30.C [new file with mode: 0644]

index f86e4f7fdbd1623fbea2ae3de18f459b30966f12..5318c3e41da6817d7e6344b82e8031ba7f1ddfd0 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35336
+       * c-pretty-print.c (pp_c_postfix_expression): Handle BIT_FIELD_REF.
+       (pp_c_expression): Likewise.
+
 2008-12-05  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR c/38416
index 9ee2738ca82ac2acb75579abdcd5913bebb5290c..cf1c6c3f52c2f0035e048612069db76236011a3f 100644 (file)
@@ -1444,6 +1444,36 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
       }
       break;
 
+    case BIT_FIELD_REF:
+      {
+       tree type = TREE_TYPE (e);
+
+       type = signed_or_unsigned_type_for (TYPE_UNSIGNED (type), type);
+       if (type
+           && tree_int_cst_equal (TYPE_SIZE (type), TREE_OPERAND (e, 1)))
+         {
+           HOST_WIDE_INT bitpos = tree_low_cst (TREE_OPERAND (e, 2), 0);
+           HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (type), 0);
+           if ((bitpos % size) == 0)
+             {
+               pp_c_left_paren (pp);
+               pp_c_left_paren (pp);
+               pp_type_id (pp, type);
+               pp_c_star (pp);
+               pp_c_right_paren (pp);
+               pp_c_ampersand (pp);
+               pp_expression (pp, TREE_OPERAND (e, 0));
+               pp_c_right_paren (pp);
+               pp_c_left_bracket (pp);
+               pp_wide_integer (pp, bitpos / size);
+               pp_c_right_bracket (pp);
+               break;
+             }
+         }
+       pp_unsupported_tree (pp, e);
+      }
+      break;
+
     case COMPLEX_CST:
     case VECTOR_CST:
       pp_c_compound_literal (pp, e);
@@ -1955,6 +1985,7 @@ pp_c_expression (c_pretty_printer *pp, tree e)
     case ARRAY_REF:
     case CALL_EXPR:
     case COMPONENT_REF:
+    case BIT_FIELD_REF:
     case COMPLEX_CST:
     case COMPLEX_EXPR:
     case VECTOR_CST:
index c70307ca2f85bf336d8c5b72b62e7d1a4e77d8ed..dab6ed0def0e82c68841898fcb630ec8d8351726 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35336
+       * error.c (dump_expr): Handle BIT_FIELD_REF.
+
 2008-12-05  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR bootstrap/38262
index a2db1575fe70c2d694cb5c0e3a6745c0b3613316..4a63f1df8137a6d53b7d8d71d5386b7ec4558053 100644 (file)
@@ -2071,6 +2071,7 @@ dump_expr (tree t, int flags)
     case UNEQ_EXPR:
     case LTGT_EXPR:
     case COMPLEX_EXPR:
+    case BIT_FIELD_REF:
       pp_expression (cxx_pp, t);
       break;
 
index f4843d5b5075d22df404cf5ac7a18a037e787a38..b841930c2c6c1350ccfae28254ba095a731e2395 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35336
+       * g++.dg/other/error30.C: New test.
+
 2008-12-05  Janis Johnson  <janis187@us.ibm.com>
 
        * lib/target-supports.exp (check_effective_target_hard_dfp): New.
diff --git a/gcc/testsuite/g++.dg/other/error30.C b/gcc/testsuite/g++.dg/other/error30.C
new file mode 100644 (file)
index 0000000..2df0e64
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/35336
+// { dg-do compile }
+// { dg-bogus "not supported by" "" { target *-*-* } 0 }
+
+struct A
+{
+  int i : 2;
+};
+
+void foo (bool b)
+{
+  A a;
+  (a.i || b) ();       // { dg-error "cannot be used as" }
+}