libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-36.c
blob56e59a431a49c668b9e9b3e97fbb709363c852c0
1 /* PR tree-optimization/78450 - strlen(s) return value can be assumed
2 to be less than the size of s
3 { dg-do compile }
4 { dg-options "-O2 -fdump-tree-optimized" } */
6 #include "strlenopt.h"
8 extern char a7[7], a6[6], a5[5], a4[4], a3[3], a2[2], a1[1];
9 extern char a0[0]; /* Intentionally not tested here. */
10 extern char ax[]; /* Same. */
12 extern void failure_on_line (int);
14 #define TEST_FAIL(line) \
15 do { \
16 failure_on_line (line); \
17 } while (0)
19 #define T(expr) \
20 if (!(expr)) TEST_FAIL (__LINE__); else (void)0
23 void test_array (void)
25 T (strlen (a7) < sizeof a7);
26 T (strlen (a6) < sizeof a6);
27 T (strlen (a5) < sizeof a5);
28 T (strlen (a4) < sizeof a4);
29 T (strlen (a3) < sizeof a3);
31 /* The following two calls are folded too early which defeats
32 the strlen() optimization.
33 T (strlen (a2) == 1);
34 T (strlen (a1) == 0); */
37 /* { dg-final { scan-tree-dump-not "failure_on_line" "optimized" } } */