Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-87.c
blob082c7b2f7342d6ee759cbe41521a9f285571ad0b
1 /* PR tree-optimization/92157 - incorrect strcmp() == 0 result for unknown
2 strings​
3 { dg-do run }
4 { dg-options "-O2 -Wall" } */
6 #include "strlenopt.h"
9 char a2[2], a3[3];
12 static inline __attribute__ ((always_inline)) int
13 verify_not_equal (const char *s, const char *t, int x)
15 int n = x < 0 ? strlen (s) : 0 < x ? strlen (t) : strlen (s) + strlen (t);
17 if (strcmp (t, s) == 0)
18 abort ();
20 return n;
23 __attribute__ ((noipa)) int test_a2_s (const char *s)
25 return verify_not_equal (a2, s, 0);
28 __attribute__ ((noipa)) int test_a2_a3 (void)
30 return verify_not_equal (a2, a3, 0);
33 __attribute__ ((noipa)) int test_a3_a2 (void)
35 return verify_not_equal (a3, a2, 0);
38 __attribute__ ((noipa)) int test_s_a2 (const char *s)
40 return verify_not_equal (s, a2, 0);
44 __attribute__ ((noipa)) int test_a2_s_1 (const char *s)
46 return verify_not_equal (a2, s, -1);
49 __attribute__ ((noipa)) int test_a2_a3_1 (void)
51 return verify_not_equal (a2, a3, -1);
54 __attribute__ ((noipa)) int test_a3_a2_1 (void)
56 return verify_not_equal (a3, a2, -1);
59 __attribute__ ((noipa)) int test_s_a2_1 (const char *s)
61 return verify_not_equal (s, a2, -1);
65 __attribute__ ((noipa)) int test_a2_s_2 (const char *s)
67 return verify_not_equal (a2, s, +1);
70 __attribute__ ((noipa)) int test_a2_a3_2 (void)
72 return verify_not_equal (a2, a3, +1);
75 __attribute__ ((noipa)) int test_a3_a2_2 (void)
77 return verify_not_equal (a3, a2, +1);
80 __attribute__ ((noipa)) int test_s_a2_2 (const char *s)
82 return verify_not_equal (s, a2, +1);
85 int main (void)
87 a2[0] = '1';
88 a3[0] = '1';
89 a3[0] = '2';
91 test_a2_s ("");
92 test_a2_a3 ();
93 test_a3_a2 ();
94 test_s_a2 ("");
96 test_a2_s_1 ("");
97 test_a2_a3_1 ();
98 test_a3_a2_1 ();
99 test_s_a2_1 ("");
101 test_a2_s_2 ("");
102 test_a2_a3_2 ();
103 test_a3_a2_2 ();
104 test_s_a2_2 ("");