comparison gcc/testsuite/gcc.dg/strlenopt-87.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* PR tree-optimization/92157 - incorrect strcmp() == 0 result for unknown
2 strings​
3 { dg-do run }
4 { dg-options "-O2 -Wall" } */
5
6 #include "strlenopt.h"
7
8
9 char a2[2], a3[3];
10
11
12 static inline __attribute__ ((always_inline)) int
13 verify_not_equal (const char *s, const char *t, int x)
14 {
15 int n = x < 0 ? strlen (s) : 0 < x ? strlen (t) : strlen (s) + strlen (t);
16
17 if (strcmp (t, s) == 0)
18 abort ();
19
20 return n;
21 }
22
23 __attribute__ ((noipa)) int test_a2_s (const char *s)
24 {
25 return verify_not_equal (a2, s, 0);
26 }
27
28 __attribute__ ((noipa)) int test_a2_a3 (void)
29 {
30 return verify_not_equal (a2, a3, 0);
31 }
32
33 __attribute__ ((noipa)) int test_a3_a2 (void)
34 {
35 return verify_not_equal (a3, a2, 0);
36 }
37
38 __attribute__ ((noipa)) int test_s_a2 (const char *s)
39 {
40 return verify_not_equal (s, a2, 0);
41 }
42
43
44 __attribute__ ((noipa)) int test_a2_s_1 (const char *s)
45 {
46 return verify_not_equal (a2, s, -1);
47 }
48
49 __attribute__ ((noipa)) int test_a2_a3_1 (void)
50 {
51 return verify_not_equal (a2, a3, -1);
52 }
53
54 __attribute__ ((noipa)) int test_a3_a2_1 (void)
55 {
56 return verify_not_equal (a3, a2, -1);
57 }
58
59 __attribute__ ((noipa)) int test_s_a2_1 (const char *s)
60 {
61 return verify_not_equal (s, a2, -1);
62 }
63
64
65 __attribute__ ((noipa)) int test_a2_s_2 (const char *s)
66 {
67 return verify_not_equal (a2, s, +1);
68 }
69
70 __attribute__ ((noipa)) int test_a2_a3_2 (void)
71 {
72 return verify_not_equal (a2, a3, +1);
73 }
74
75 __attribute__ ((noipa)) int test_a3_a2_2 (void)
76 {
77 return verify_not_equal (a3, a2, +1);
78 }
79
80 __attribute__ ((noipa)) int test_s_a2_2 (const char *s)
81 {
82 return verify_not_equal (s, a2, +1);
83 }
84
85 int main (void)
86 {
87 a2[0] = '1';
88 a3[0] = '1';
89 a3[0] = '2';
90
91 test_a2_s ("");
92 test_a2_a3 ();
93 test_a3_a2 ();
94 test_s_a2 ("");
95
96 test_a2_s_1 ("");
97 test_a2_a3_1 ();
98 test_a3_a2_1 ();
99 test_s_a2_1 ("");
100
101 test_a2_s_2 ("");
102 test_a2_a3_2 ();
103 test_a3_a2_2 ();
104 test_s_a2_2 ("");
105 }