Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / builtin-memchr-4.c
blob58a3b444b638d4f7f849de836ce18bf94d494e02
1 /* PR tree-optimization/89772
2 Verify that memchr calls with a pointer to a constant character
3 are folded as expected.
4 { dg-do compile }
5 { dg-options "-O1 -Wall -fdump-tree-release_ssa" } */
7 typedef __SIZE_TYPE__ size_t;
8 typedef __WCHAR_TYPE__ wchar_t;
10 extern void* memchr (const void*, int, size_t);
11 extern int printf (const char*, ...);
12 extern void abort (void);
14 #define A(expr) \
15 ((expr) \
16 ? (void)0 \
17 : (printf ("assertion failed on line %i: %s\n", \
18 __LINE__, #expr), \
19 abort ()))
21 const char a[8] = {'a',0,'b'};
22 const char b[3] = {'a','b'};
23 const char c[8] = {'a','b','c'};
25 void test_memchr_cst_char (void)
27 A (!memchr (a, 'c', 2));
28 A (!memchr (a, 'c', 5));
29 A (!memchr (a, 'c', sizeof a));
30 A (&a[1] == memchr (a, 0, sizeof a));
32 A (!memchr (b, 0, 2));
33 A (&b[2] == memchr (b, 0, sizeof b));
35 A (!memchr (c, 0, 2));
36 A (&c[3] == memchr (c, 0, 4));
37 A (&c[3] == memchr (c, 0, sizeof a));
40 /* { dg-final { scan-tree-dump-not "abort" "release_ssa" } } */