Limit dg-xfail-run-if for *-*-hpux11.[012]* to -O0
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr47917.c
blob32c99c6a2d2891db2a10ddcd18b4742a25d95c58
1 /* { dg-do run } */
2 /* { dg-options "-std=c99" } */
3 /* { dg-options "-std=gnu99" { target *-*-hpux* } } */
4 /* { dg-additional-options "-D__USE_MINGW_ANSI_STDIO=1" { target *-*-mingw* } } */
5 /* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } { "-O0" } } */
7 /* PR middle-end/47917 */
9 #include <stdio.h>
10 extern int memcmp (const void *, const void *, __SIZE_TYPE__);
11 extern void abort (void);
13 char buf1[6], buf2[6], buf3[4], buf4[4];
14 int i;
16 int
17 foo (void)
19 int ret = snprintf (buf1, sizeof buf1, "abcde");
20 ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
21 ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
22 ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096;
23 return ret;
26 int
27 main (void)
29 if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
30 abort ();
31 if (memcmp (buf1, "abcde", 6) != 0
32 || memcmp (buf2, "abcde", 6) != 0
33 || memcmp (buf3, "abc", 4) != 0
34 || memcmp (buf4, "def", 4) != 0
35 || i != 2)
36 abort ();
37 return 0;