libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / builtin-sprintf-29.c
blob4d73f14cb4ade2dd8e6cc9ceae06c381f9b22c20
1 /* PR middle-end/100732 - ICE on sprintf %s with integer argument
2 { dg-do compile }
3 { dg-options "-fpermissive -O2 -Wall -fdump-tree-optimized" } */
5 #define sprintf(d, f, ...) \
6 __builtin___sprintf_chk (d, 0, 32, f, __VA_ARGS__)
9 void fi (int i, const char *s)
11 sprintf (i, "%s", s); // { dg-warning "\\\[-Wint-conversion" }
14 void gb (char *d, _Bool b)
16 sprintf (d, "%s", b); // { dg-warning "\\\[-Wformat" }
19 void gi (char *d, int i)
21 sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" }
24 void gd (char *d, double x)
26 sprintf (d, "%s", x); // { dg-warning "\\\[-Wformat" }
30 struct X { int i; };
32 void gx (char *d, struct X x)
34 sprintf (d, "%s", x); // { dg-warning "\\\[-Wformat" }
38 /* Also verify that the invalid sprintf call isn't folded to strcpy.
39 { dg-final { scan-tree-dump-times "sprintf_chk" 5 "optimized" } }
40 { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */