This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Backported patch for bug 27558


Bug 27558 was reported as a regression present in 4.2, but my testing
indicates it actually only remains in 4.0 and 4.1.  I've applied this
backport patch to fix it on 4.1 branch and will commit to 4.0 branch
subject to testing there.  Bootstrapped with no regressions on
i686-pc-linux-gnu.

2006-08-25  Joseph Myers  <joseph@codesourcery.com>

	PR c/27558
	Backport:
	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)).

testsuite:
2006-08-25  Joseph Myers  <joseph@codesourcery.com>

	PR c/27558
	Backport:
	2006-04-20  Jakub Jelinek  <jakub@redhat.com>
	* gcc.dg/20060419-1.c: New test.

Index: c-pretty-print.c
===================================================================
--- c-pretty-print.c	(revision 113111)
+++ c-pretty-print.c	(revision 113112)
@@ -521,7 +521,16 @@
     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: testsuite/gcc.dg/20060419-1.c
===================================================================
--- testsuite/gcc.dg/20060419-1.c	(revision 0)
+++ testsuite/gcc.dg/20060419-1.c	(revision 113112)
@@ -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\\\]" } */
+};

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]