1 /* Verify that calls to non-modifying built-ins aren't considered
4 { dg-options "-O2 -Wall" }
5 { dg-require-effective-target alloca } */
7 typedef __SIZE_TYPE__
size_t;
10 void* calloc (size_t, size_t);
11 void* malloc (size_t);
12 int printf (const char *, ...);
13 int scanf (const char *, ...);
14 int sprintf (char *, const char *, ...);
15 int snprintf (char *, size_t, const char *, ...);
16 int puts (const char *);
17 char* strcpy (char*, const char*);
18 size_t strlen (const char*);
26 void nowarn_noproto (const char *fmt
)
33 void nowarn_scanf (const char *fmt
)
40 void test_puts_sprintf_alloca (const char *fmt
)
45 sprintf (a
, fmt
, p
); // fmt might contain %n
51 snprintf (0, 0, fmt
, p
); // same as above
56 void test_puts_alloca (const char *s
)
65 puts (p
); // { dg-warning "-Wuninitialized" }
68 p
= alloca (strlen (s
) + 1);
74 /* Verify that the puts() calls above isn't considered to have
75 potentially modified *P, and same for the one below. */
76 p
= alloca (strlen (s
));
77 puts (p
); // { dg-warning "-Wuninitialized" }
78 puts (p
+ 1); // { dg-warning "-Wuninitialized" }
83 void test_puts_malloc (const char *s
, const char *t
)
88 p
= malloc (strlen (s
) + 1);
94 p
= malloc (strlen (t
));
95 puts (p
); // { dg-warning "-Wuninitialized" }
100 void test_puts_vla (const char *s
, const char *t
)
103 char a
[strlen (s
) + 1];
110 puts (b
); // { dg-warning "-Wuninitialized" }
115 void test_printf_puts (const char *s
)
117 char *p
= __builtin_malloc (1);
121 puts (p
); // { dg-warning "-Wuninitialized" }