testsuite: RISC-V: Ignore pr118170.c for E ABI
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-59.c
blob9bacf8748765d26d6cc89c30d946ef40f53ed31d
1 /* Verify that strlen() calls with constant conditional expressions are
2 eliminated as expected.
4 { dg-do compile }
5 { dg-options "-O1 -fdump-tree-optimized" } */
7 extern void abort (void);
8 extern __SIZE_TYPE__ strlen (const char*);
11 #define CAT(x, y) x ## y
12 #define CONCAT(x, y) CAT (x, y)
13 #define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__)
15 #define FAIL(name) do { \
16 extern void FAILNAME (name) (void); \
17 FAILNAME (name)(); \
18 } while (0)
20 /* Macros to emit a call to funcation named
21 call_failed_to_be_eliminated_on_line_NNN()
22 for each call that's expected to be eliminated. The dg-final
23 scan-tree-dump-time directive at the bottom of the test verifies
24 that no such call appears in output. */
25 #define ELIM(expr) \
26 if ((expr)) FAIL (test_not_eliminated); else (void)0
28 extern char a3[3];
29 extern char a7[7];
31 struct MemArrays { char a[7], b[9]; };
33 struct MemArrays ma;
35 void test_elim_condexpr (int i)
37 ELIM (6 < strlen (i ? "" : "123456"));
38 ELIM (6 < strlen (i ? "123456" : ""));
40 ELIM (4 < strlen (i < 1 ? "a" : i == 1 ? "ab" : "abc"));
42 ELIM (3 < strlen (i ? "" : a3));
43 ELIM (3 < strlen (i ? a3 : "1"));
45 ELIM (6 < strlen (i ? "12" : a7));
46 ELIM (6 < strlen (i ? a7 : "123"));
48 ELIM (6 < strlen (i ? "1234" : a7));
49 ELIM (7 < strlen (i ? a7 : "1234567"));
51 ELIM (3 < strlen (i < 1 ? "a" : i == 1 ? "ab" : a3));
52 ELIM (3 < strlen (i < 1 ? "a" : i == 1 ? a3 : "abc"));
53 ELIM (3 < strlen (i < 1 ? a3 : i == 1 ? "a" : "abc"));
55 ELIM (6 < strlen (i < 1 ? "a" : i == 1 ? "ab" : a7));
56 ELIM (6 < strlen (i < 1 ? "a" : i == 1 ? a7 : "abc"));
57 ELIM (6 < strlen (i < 1 ? a7 : i == 1 ? "a" : "abc"));
59 ELIM (6 < strlen (i < 1 ? "a" : i == 1 ? a7 : a3));
60 ELIM (6 < strlen (i < 1 ? a7 : i == 1 ? "a" : a3));
63 enum { maxlen = sizeof ma - 1 };
64 ELIM (maxlen < strlen (ma.a));
68 enum { maxlen = sizeof ma - __builtin_offsetof (struct MemArrays, b) - 1 };
69 ELIM (maxlen < strlen (ma.b));
73 /* { dg-final { scan-tree-dump-times "test_not_eliminated_" 0 "optimized" } } */