Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / pr80776-1.c
blobb9bce62d98209321b76ae33103ae26d4b9cf09ef
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wformat-overflow" } */
4 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
5 __attribute__ ((__nothrow__ , __leaf__)) sprintf (char *__restrict __s, const char *__restrict __fmt, ...)
7 return __builtin___sprintf_chk (__s, 2 - 1,
8 __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());
10 char number[sizeof "999999"];
11 int somerandom (void);
12 void
13 Foo (void)
15 int i = somerandom ();
16 if (! (0 <= i))
17 __builtin_unreachable ();
18 if (! (0 <= i && i <= 999999))
19 __builtin_unreachable ();
21 /* Legacy evrp sets the range of i to [0, MAX] *before* the first conditional,
22 and to [0,999999] *before* the second conditional. This is because both
23 evrp and VRP use trickery to set global ranges when this particular use of
24 a __builtin_unreachable is in play (see uses of
25 assert_unreachable_fallthru_edge_p).
27 Setting these ranges at the definition site, causes VRP to remove the
28 unreachable code altogether, leaving the following sprintf unguarded. This
29 causes the bogus warning below. */
30 sprintf (number, "%d", i); /* { dg-bogus "writing" "" } */