aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-11.c
blob: 73117c49a734f7213926ba16e01cb97b04d1da5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* PR middle-end/100732 - ICE on sprintf %s with integer argument
   { dg-do compile }
   { dg-options "-O2 -Wall -fdump-tree-optimized" } */

char d[32];

void gb (_Bool b)
{
  __builtin_snprintf (d, 32, "%s", b);  // { dg-warning "\\\[-Wformat" }
}

void gi (int i)
{
  __builtin_snprintf (d, 32, "%s", i);  // { dg-warning "\\\[-Wformat" }
}

void gd (char *d, double x)
{
  __builtin_snprintf (d, 32, "%s", x);  // { dg-warning "\\\[-Wformat" }
}


struct X { int i; };

void gx (char *d, struct X x)
{
  __builtin_snprintf (d, 32, "%s", x);  // { dg-warning "\\\[-Wformat" }
}

/* Also verify that the invalid sprintf call isn't folded to strcpy.
   { dg-final { scan-tree-dump-times "snprintf" 4 "optimized" } }
   { dg-final { scan-tree-dump-not "strcpy" "optimized" } } */