Patchwork [fixincludes,testsuite] Fix g++.dg/warn/miss-format-1.C on Solaris 8/9 (PR c++/46024)

login
register
mail settings
Submitter Rainer Orth
Date Oct. 19, 2010, 12:52 p.m.
Message ID <yddocaqcpkj.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/68329/
State New
Headers show

Comments

Rainer Orth - Oct. 19, 2010, 12:52 p.m.
As described in the PR, g++.dg/warn/miss-format-1.C fails on Solaris 8
and 9 in various ways.  The worst is i386-pc-solaris2.8:

FAIL: g++.dg/warn/miss-format-1.C printf attribute warning (test for warnings,
line 17)
FAIL: g++.dg/warn/miss-format-1.C printf attribute warning 2 (test for
warnings, line 42)
FAIL: g++.dg/warn/miss-format-1.C (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/miss-format-1.C:26:18:
error: 'vscanf' was not declared in this scope

The excess errors can be fixed by enclosing the target list in braces.
The missing attribute warning happens because on i386 (unlike sparc,
which uses the default, void *) va_list is char *, which doesn't match
<sys/va_list.h> with C++:

#ifdef __STDC__
typedef void *__va_list;
#else
typedef char *__va_list;
#endif

The FAILs don't occur on Solaris 10+ because that version of
<sys/va_list.h> has the equivalent of

#ifdef __GNUC__
typedef __builtin_va_list __gnuc_va_list;
typedef __builtin_va_list __va_list;
#endif

I'm introducing an equivalent change via fixincludes.

Bootstrapped without regressions on i386-pc-solaris2.10 and
i386-pc-solaris2.9.  sparc-sun-solaris2.8 and sparc-sun-solaris2.10
bootstraps still running.

Ok for mainline, 4.4 and 4.5 branches?

	Rainer


2010-06-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	fixincludes:
	PR c++/46024
	* inclhack.def (solaris_sys_va_list): New fix.
	* fixincl.x: Regenerate.
	* tests/base/sys/va_list.h: New test.

	gcc/testsuite:
	PR c++/46024
	* g++.dg/warn/miss-format-1.C: Enclose dg-error target list in braces.
Bruce Korb - Oct. 19, 2010, 2:32 p.m.
Hi Rainer,

On Tue, Oct 19, 2010 at 5:52 AM, Rainer Orth  wrote:
> Bootstrapped without regressions on i386-pc-solaris2.10 and
> i386-pc-solaris2.9.  sparc-sun-solaris2.8 and sparc-sun-solaris2.10
> bootstraps still running.
>
> Ok for mainline, 4.4 and 4.5 branches?

Looks good to me!  Thanks - Bruce

> 2010-06-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>        fixincludes:
>        PR c++/46024
>        * inclhack.def (solaris_sys_va_list): New fix.
>        * fixincl.x: Regenerate.
>        * tests/base/sys/va_list.h: New test.

Patch

diff -r 96768db556ed fixincludes/inclhack.def
--- a/fixincludes/inclhack.def	Mon Oct 18 23:09:29 2010 +0200
+++ b/fixincludes/inclhack.def	Tue Oct 19 14:41:59 2010 +0200
@@ -3694,6 +3694,34 @@ 
 
 
 /*
+ * On Solaris 8 and 9, __va_list needs to become a typedef for
+ * __builtin_va_list to make -Wmissing-format-attribute work.
+ */
+fix = {
+    hackname = solaris_sys_va_list;
+    files    = sys/va_list.h;
+    mach     = '*-*-solaris2.[89]';
+    select   = "#if.*__STDC__.*\n"
+	       "typedef void \\*__va_list;\n"
+	       "#else\n"
+	       "typedef char \\*__va_list;\n"
+	       "#endif";
+
+    c_fix    = format;
+    c_fix_arg = "#ifdef __GNUC__\n"
+		"typedef __builtin_va_list __va_list;\n"
+		"#else\n"
+		"%0\n"
+		"#endif";
+    test_text = "#if defined(__STDC__) && !defined(__ia64)\n"
+    		"typedef void *__va_list;\n"
+	        "#else\n"
+	        "typedef char *__va_list;\n"
+	        "#endif";
+};
+
+
+/*
  *  a missing semi-colon at the end of the statsswtch structure definition.
  */
 fix = {
diff -r 96768db556ed fixincludes/tests/base/sys/va_list.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fixincludes/tests/base/sys/va_list.h	Tue Oct 19 14:41:59 2010 +0200
@@ -0,0 +1,22 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/sys/va_list.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( SOLARIS_SYS_VA_LIST_CHECK )
+#ifdef __GNUC__
+typedef __builtin_va_list __va_list;
+#else
+#if defined(__STDC__) && !defined(__ia64)
+typedef void *__va_list;
+#else
+typedef char *__va_list;
+#endif
+#endif
+#endif  /* SOLARIS_SYS_VA_LIST_CHECK */
diff -r 96768db556ed gcc/testsuite/g++.dg/warn/miss-format-1.C
--- a/gcc/testsuite/g++.dg/warn/miss-format-1.C	Mon Oct 18 23:09:29 2010 +0200
+++ b/gcc/testsuite/g++.dg/warn/miss-format-1.C	Tue Oct 19 14:41:59 2010 +0200
@@ -4,7 +4,7 @@ 
 /* { dg-options "-Wmissing-format-attribute" } */
 /* { dg-options "-Wmissing-format-attribute -Wno-abi" { target arm_eabi } } */
 /* VxWorks does not provide vscanf, either in kernel or RTP mode.  */
-/* { dg-error "not declared" "" { target *-*-solaris2.8 *-*-vxworks*  alpha*-dec-osf5* } 26 } */
+/* { dg-error "not declared" "" { target { *-*-solaris2.8 *-*-vxworks* alpha*-dec-osf5* } } 26 } */
 
 #include <stdio.h>
 #include <stdarg.h>