PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / builtin-sprintf-warn-6.c
blob16729798900c494027c4f4c55a8118c84a037206
1 /* PR middle-end/77721 - -Wformat-overflow not uses arg range for converted vars
2 Test to verify that the correct range information is made available to the
3 -Wformat-lenght check to prevent warnings. */
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -Wformat -Wformat-overflow -fdump-tree-optimized" } */
7 void abort (void);
8 int snprintf (char*, __SIZE_TYPE__, const char*, ...);
10 void fuchar (unsigned char j, char *p)
12 if (j > 99)
13 return;
15 if (3 != snprintf (p, 4, "%3hu", j))
16 abort ();
19 void fschar (signed char j, char *p)
21 const unsigned char k = (unsigned char) j;
23 if (k > 99)
24 return;
26 if (3 != snprintf (p, 4, "%3hhu", k))
27 abort ();
30 void fushrt (unsigned short j, char *p)
32 if (j > 999)
33 return;
35 if (3 != snprintf (p, 4, "%3hu", j))
36 abort ();
39 void fshrt (short j, char *p)
41 const unsigned short k = (unsigned short) j;
43 if (k > 999)
44 return;
46 if (3 != snprintf (p, 4, "%3hu", k))
47 abort ();
50 void fuint (unsigned j, char *p)
52 if (j > 999)
53 return;
55 snprintf (p, 4, "%3u", j);
58 void fint (int j, char *p)
60 const unsigned k = (unsigned) j;
62 if (k > 999)
63 return;
65 snprintf (p, 4, "%3u", k);
68 void fulong (unsigned long j, char *p)
70 if (j > 999)
71 return;
73 snprintf (p, 4, "%3lu", j);
76 void flong (long j, char *p)
78 const unsigned long k = (unsigned long) j;
80 if (k > 999)
81 return;
83 snprintf (p, 4, "%3lu", k);
86 void fullong (unsigned long long j, char *p)
88 if (j > 999)
89 return;
91 snprintf (p, 4, "%3llu", j);
94 void fllong (long long j, char *p)
96 const unsigned long long k = (unsigned long long) j;
98 if (k > 999)
99 return;
101 snprintf (p, 4, "%3llu", k);
104 /* { dg-final { scan-tree-dump-not "abort" "optimized" } } */