public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/108159] New: gcc.dg/format/ms-format2.c fails due to warning message change
@ 2022-12-17 21:23 nightstrike at gmail dot com
  2022-12-17 21:33 ` [Bug testsuite/108159] " nightstrike at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: nightstrike at gmail dot com @ 2022-12-17 21:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108159

            Bug ID: 108159
           Summary: gcc.dg/format/ms-format2.c fails due to warning
                    message change
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

This is presumably a regression, as the test worked when it first went in. 
However, the warning message being tested for has since changed the line that
gets reported:

  printf (XXX, p); /* { dg-warning "format" "bad argument types" } */
  printf ("%I32x", f); /* { dg-warning "format" "bad argument types" } */
  printf ("%I64x", d); /* { dg-warning "format" "bad argument types" } */

gcc.dg/format/ms-format2.c: In function 'foo':
gcc.dg/format/ms-format2.c:12:13: warning: format '%I64x' expects argument of
type 'long long unsigned int', but argument 2 has type 'void *' [-Wformat=]
gcc.dg/format/ms-format2.c:20:11: note: in expansion of macro 'XXX'
gcc.dg/format/ms-format2.c:12:18: note: format string is defined here
gcc.dg/format/ms-format2.c:21:16: warning: format '%I32x' expects argument of
type 'long unsigned int', but argument 2 has type 'double' [-Wformat=]
gcc.dg/format/ms-format2.c:22:16: warning: format '%I64x' expects argument of
type 'long long unsigned int', but argument 2 has type 'double' [-Wformat=]
FAIL: gcc.dg/format/ms-format2.c   -DWIDE  bad argument types (test for
warnings, line 20)
PASS: gcc.dg/format/ms-format2.c   -DWIDE  bad argument types (test for
warnings, line 21)
PASS: gcc.dg/format/ms-format2.c   -DWIDE  bad argument types (test for
warnings, line 22)
FAIL: gcc.dg/format/ms-format2.c   -DWIDE  (test for excess errors)
Excess errors:
gcc.dg/format/ms-format2.c:12:13: warning: format '%I64x' expects argument of
type 'long long unsigned int', but argument 2 has type 'void *' [-Wformat=]


I assume the fix is to move the dg-warning to the macro definition line, but I
don't know how to distinguish between the 32 and 64-bit cases in dejagnu.  To
be clear, the following change makes the test work for the 64-bit case:

diff --git a/gcc/testsuite/gcc.dg/format/ms-format2.c
b/gcc/testsuite/gcc.dg/format/ms-format2.c
index 5c950522a7c..e56bfc4a9c4 100644
--- a/gcc/testsuite/gcc.dg/format/ms-format2.c
+++ b/gcc/testsuite/gcc.dg/format/ms-format2.c
@@ -9,7 +9,7 @@
 #include "format.h"

 #ifdef _WIN64
-#define XXX "%I64x"
+#define XXX "%I64x" /* { dg-warning "format" "bad argument types" } */
 #else
 #define XXX "%I32x"
 #endif
@@ -17,7 +17,7 @@
 void
 foo (float f, double d, void *p)
 {
-  printf (XXX, p); /* { dg-warning "format" "bad argument types" } */
+  printf (XXX, p);
   printf ("%I32x", f); /* { dg-warning "format" "bad argument types" } */
   printf ("%I64x", d); /* { dg-warning "format" "bad argument types" } */
 }



But that won't address the 32-bit case.  I suppose there's some other  "{}"
thing to put on both #define XXX lines to choose which architecture, but I
don't know what that would be.  Hopefully this is enough diagnosis for someone
more knowledgeable to pick it up and run with it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug testsuite/108159] gcc.dg/format/ms-format2.c fails due to warning message change
  2022-12-17 21:23 [Bug testsuite/108159] New: gcc.dg/format/ms-format2.c fails due to warning message change nightstrike at gmail dot com
@ 2022-12-17 21:33 ` nightstrike at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: nightstrike at gmail dot com @ 2022-12-17 21:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108159

--- Comment #1 from nightstrike <nightstrike at gmail dot com> ---
Andrew pointed out that this is the better fix, and it does indeed work:

diff --git a/gcc/testsuite/gcc.dg/format/ms-format2.c
b/gcc/testsuite/gcc.dg/format/ms-format2.c
index 5c950522a7c..9d21d108642 100644
--- a/gcc/testsuite/gcc.dg/format/ms-format2.c
+++ b/gcc/testsuite/gcc.dg/format/ms-format2.c
@@ -3,7 +3,7 @@
 */
 /* Origin: Kai Tietz <kai.tietz@onevision.com> */
 /* { dg-do compile { target { *-*-mingw* } } } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat -Wno-pedantic-ms-format"
} */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat -Wno-pedantic-ms-format
-ftrack-macro-expansion=0" } */

 #define USE_SYSTEM_FORMATS
 #include "format.h"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-17 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-17 21:23 [Bug testsuite/108159] New: gcc.dg/format/ms-format2.c fails due to warning message change nightstrike at gmail dot com
2022-12-17 21:33 ` [Bug testsuite/108159] " nightstrike at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).