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]

[PATCH,ARM] fix warnings that cause PR bootstrap/45444


This fixes two compilation warnings in the ARM backend that result in
a bootstrap failure with current trunk on ARM (PR bootstrap/45444).

The first set of warnings:

/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c: In function 'locate_neon_builtin_icode':
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:18913:22: error: uninitialized const member in 'neon_builtin_datum' is invalid in C++ [-Werror=c++-compat]
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:17969:20: note: 'itype' should be initialized
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:18913:22: error: uninitialized const member in 'neon_builtin_datum' is invalid in C++ [-Werror=c++-compat]
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:17970:13: note: 'bits' should be initialized
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:18913:22: error: uninitialized const member in 'neon_builtin_datum' is invalid in C++ [-Werror=c++-compat]
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:17971:24: note: 'codes' should be initialized
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:18913:22: error: uninitialized const member in 'neon_builtin_datum' is invalid in C++ [-Werror=c++-compat]
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:17972:22: note: 'num_vars' should be initialized

arise because a search key is wrapped in a larger struct before being
passed to bsearch and a comparison function, and that struct has a
number of const fields that remain initialized in this case.  The
wrapping is unnecessary, and removing it fixes the warnings.

The second warning:

/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c: In function 'arm_output_asm_insn':
/home/mikpe/gcc-4.6-20100828/gcc/config/arm/arm.c:22649:3: error: function might be possible candidate for 'gnu_printf' format attribute [-Werror=missing-format-attribute]

arises because arm_output_asm_insn calls va_start and vsprintf, so
gcc deduces that it should have a printf format attribute.  Adding
ATTRIBUTE_PRINTF_4 to the declation fixes the warning.

Tested natively on arm-linux-gnueabi, as well as in an i686->arm cross
built with -Wc++-compat -Wmissing-format-attribute in CFLAGS.  The native
build now proceeds to the end of stage3 where it dies due to unrelated
bootstrap comparison failures.

Ok for trunk? (I don't have svn write access.)

gcc/

2010-09-01  Mikael Pettersson  <mikpe@it.uu.se>

	PR bootstrap/45444
	* config/arm/arm.c (locate_neon_builtin_icode): Pass &fcode
	to neon_builtin_compare via bsearch.  Remove variable key.
	(neon_builtin_compare): Adjust.
	(arm_output_asm_insn): Declare with ATTRIBUTE_PRINTF_4.

--- gcc-4.6-20100828/gcc/config/arm/arm.c.~1~	2010-08-25 17:35:24.000000000 +0200
+++ gcc-4.6-20100828/gcc/config/arm/arm.c	2010-09-01 15:41:33.000000000 +0200
@@ -18894,9 +18894,8 @@ arm_expand_unop_builtin (enum insn_code 
 static int
 neon_builtin_compare (const void *a, const void *b)
 {
-  const neon_builtin_datum *const key = (const neon_builtin_datum *) a;
+  unsigned int soughtcode = *(const int *) a;
   const neon_builtin_datum *const memb = (const neon_builtin_datum *) b;
-  unsigned int soughtcode = key->base_fcode;
 
   if (soughtcode >= memb->base_fcode
       && soughtcode < memb->base_fcode + memb->num_vars)
@@ -18910,12 +18909,11 @@ neon_builtin_compare (const void *a, con
 static enum insn_code
 locate_neon_builtin_icode (int fcode, neon_itype *itype)
 {
-  neon_builtin_datum key, *found;
+  neon_builtin_datum *found;
   int idx;
 
-  key.base_fcode = fcode;
   found = (neon_builtin_datum *)
-    bsearch (&key, &neon_builtin_data[0], ARRAY_SIZE (neon_builtin_data),
+    bsearch (&fcode, &neon_builtin_data[0], ARRAY_SIZE (neon_builtin_data),
 		   sizeof (neon_builtin_data[0]), neon_builtin_compare);
   gcc_assert (found);
   idx = fcode - (int) found->base_fcode;
@@ -22638,7 +22636,7 @@ arm_count (int label,
    it to output_asm_insn.  Provides a mechanism to construct the
    output pattern on the fly.  Note the hard limit on the pattern
    buffer size.  */
-static void
+static void ATTRIBUTE_PRINTF_4
 arm_output_asm_insn (emit_f emit, int label, rtx *operands,
 		     const char *pattern, ...)
 {


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