2018-04-09 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / builtins-85.c
blob0993fbc19f4b2a48456176be349358c69ac3cebb
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
4 typedef __SIZE_TYPE__ size_t;
5 extern void __chk_fail (void);
6 extern int snprintf (char *, size_t, const char *, ...);
7 extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...)
9 if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b)
10 __chk_fail ();
11 return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ());
13 extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf");
15 char buf[10];
17 int
18 main (void)
20 snprintf (buf, 10, "%d%d\n", 10, 10);
21 return 0;
24 /* { dg-final { scan-assembler "mysnprintf" } } */
25 /* { dg-final { scan-assembler-not "__chk_fail" } } */