1 /* PR c/84919 - bogus -Wrestrict on sprintf %p with destination as argument
3 -O2 isn't strictly necessary but setting also verifies that the sprintf/
4 strlen pass doesn't warn with non-constant arguments.
5 { dg-options "-O2 -Wall" } */
7 extern int sprintf (char* restrict
, const char* restrict
, ...);
8 extern int snprintf (char* restrict
, __SIZE_TYPE__
, const char* restrict
, ...);
12 void test_warn (char *p
)
15 sprintf (a
, "a=%s", a
); /* { dg-warning "-Wrestrict" } */
19 sprintf (p
, "a=%s", q
); /* { dg-warning "-Wrestrict" } */
22 void test_nowarn_front_end (char *d
)
25 snprintf (d
, 32, "%p", d
);
27 sprintf (a
, "p=%p", a
);
28 snprintf (a
, sizeof a
, "%p", a
);
31 void test_nowarn_sprintf_pass (char *d
)
35 sprintf (d
, "p=%p", q
);
36 snprintf (d
, 32, "p=%p", q
);
39 sprintf (a
, "a=%p", q
);
40 snprintf (a
, sizeof a
, "a=%p", q
);