OSDN Git Service

* c-pretty-print.c (pp_c_direct_abstract_declarator): Print
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Apr 2006 09:04:26 +0000 (09:04 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Apr 2006 09:04:26 +0000 (09:04 +0000)
TYPE_MAX_VALUE (TYPE_DOMAIN (t)) + 1 for ARRAY_TYPE rather
than plain TYPE_MAX_VALUE (TYPE_DOMAIN (t)).

* gcc.dg/20060419-1.c: New test.

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

gcc/ChangeLog
gcc/c-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20060419-1.c [new file with mode: 0644]

index 978e128..ba42b12 100644 (file)
@@ -1,3 +1,9 @@
+2006-04-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-pretty-print.c (pp_c_direct_abstract_declarator): Print
+       TYPE_MAX_VALUE (TYPE_DOMAIN (t)) + 1 for ARRAY_TYPE rather
+       than plain TYPE_MAX_VALUE (TYPE_DOMAIN (t)).
+
 2006-04-20  Alan Modra  <amodra@bigpond.net.au>
 
        * config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Consume all
index 6701567..9b9add2 100644 (file)
@@ -521,7 +521,16 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
     case ARRAY_TYPE:
       pp_c_left_bracket (pp);
       if (TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t)))
-        pp_expression (pp, TYPE_MAX_VALUE (TYPE_DOMAIN (t)));
+       {
+         tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (t));
+         tree type = TREE_TYPE (maxval);
+
+         if (host_integerp (maxval, 0))
+           pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
+         else
+           pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval,
+                                           build_int_cst (type, 1)));
+       }
       pp_c_right_bracket (pp);
       pp_direct_abstract_declarator (pp, TREE_TYPE (t));
       break;
index b6772a0..bbc744f 100644 (file)
@@ -1,3 +1,7 @@
+2006-04-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20060419-1.c: New test.
+
 2006-04-19  Carlos O'Donell  <carlos@codesourcery.com>
 
        PR c/26774
diff --git a/gcc/testsuite/gcc.dg/20060419-1.c b/gcc/testsuite/gcc.dg/20060419-1.c
new file mode 100644 (file)
index 0000000..7547741
--- /dev/null
@@ -0,0 +1,4 @@
+struct T {
+  unsigned char f[1] __attribute__((packed)); /* { dg-warning "ignored for field of type.*unsigned char\\\[1\\\]" } */
+  unsigned char g[14] __attribute__((packed)); /* { dg-warning "ignored for field of type.*unsigned char\\\[14\\\]" } */
+};