libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / uninit-pr101494.c
blob3c68d1495931906d3691192d1442319be6c9d6b1
1 /* PR middle-end/101494 - bogus -Wmaybe-uninitialized on memrchr of size 0
2 { dg-do compile }
3 { dg-options "-O2 -Wall" }
4 { dg-require-effective-target alloca } */
6 typedef __SIZE_TYPE__ size_t;
8 void* alloca (size_t);
10 __attribute__ ((malloc, alloc_size (1))) void* alloc (size_t);
12 __attribute__ ((access (read_only, 1, 2))) void* sink (void*, size_t);
14 void test_alloca_zero (size_t i)
16 char *p = alloca (0);
17 sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" }
20 void test_alloca_zero_pi (size_t i)
22 char *p = alloca (0);
23 sink (p + i, 0);
26 void test_alloca_cst (void)
28 char *p = alloca (7);
29 sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" }
32 void test_alloca_cst_p1 (void)
34 char *p = alloca (7);
35 sink (p + 1, 0); // { dg-bogus "\\\[-Wuninitialized" }
38 void test_alloca_cst_p7 (void)
40 char *p = alloca (7);
41 sink (p + 7, 0); // { dg-bogus "\\\[-Wuninitialized" }
44 void test_alloca_var (size_t n)
46 char *p = alloca (n);
47 sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" }
50 void test_alloca_var_p1 (size_t n)
52 char *p = alloca (n);
53 sink (p + 1, 0); // { dg-bogus "\\\[-Wuninitialized" }
56 void test_alloca_var_pn (size_t n)
58 char *p = alloca (n);
59 sink (p + n, 0); // { dg-bogus "\\\[-Wuninitialized" }