Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.c-torture / execute / builtins / strncmp-2.c
blobfe3462724ea1d4c0ec15f65e3bb06938add23cfd
1 /* Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation.
3 Ensure all expected transformations of builtin strncmp occur and
4 perform correctly.
6 Written by Kaveh R. Ghazi, 11/26/2000. */
8 extern void abort (void);
9 typedef __SIZE_TYPE__ size_t;
10 extern int strncmp (const char *, const char *, size_t);
12 void
13 main_test (void)
15 #if !defined(__OPTIMIZE__) || ((defined(__i386__) || defined (__x86_64__)) && !defined(__OPTIMIZE_SIZE__))
16 /* These tests work on platforms which support cmpstrsi. We test it
17 at -O0 on all platforms to ensure the strncmp logic is correct. */
18 const char *const s1 = "hello world";
19 const char *s2;
20 int n = 6, x;
22 s2 = s1;
23 if (strncmp (++s2, "ello", 3) != 0 || s2 != s1+1)
24 abort();
25 s2 = s1;
26 if (strncmp ("ello", ++s2, 3) != 0 || s2 != s1+1)
27 abort();
28 s2 = s1;
29 if (strncmp (++s2, "ello", 4) != 0 || s2 != s1+1)
30 abort();
31 s2 = s1;
32 if (strncmp ("ello", ++s2, 4) != 0 || s2 != s1+1)
33 abort();
34 s2 = s1;
35 if (strncmp (++s2, "ello", 5) <= 0 || s2 != s1+1)
36 abort();
37 s2 = s1;
38 if (strncmp ("ello", ++s2, 5) >= 0 || s2 != s1+1)
39 abort();
40 s2 = s1;
41 if (strncmp (++s2, "ello", 6) <= 0 || s2 != s1+1)
42 abort();
43 s2 = s1;
44 if (strncmp ("ello", ++s2, 6) >= 0 || s2 != s1+1)
45 abort();
47 s2 = s1;
48 if (strncmp (++s2, "zllo", 3) >= 0 || s2 != s1+1)
49 abort();
50 s2 = s1;
51 if (strncmp ("zllo", ++s2, 3) <= 0 || s2 != s1+1)
52 abort();
53 s2 = s1;
54 if (strncmp (++s2, "zllo", 4) >= 0 || s2 != s1+1)
55 abort();
56 s2 = s1;
57 if (strncmp ("zllo", ++s2, 4) <= 0 || s2 != s1+1)
58 abort();
59 s2 = s1;
60 if (strncmp (++s2, "zllo", 5) >= 0 || s2 != s1+1)
61 abort();
62 s2 = s1;
63 if (strncmp ("zllo", ++s2, 5) <= 0 || s2 != s1+1)
64 abort();
65 s2 = s1;
66 if (strncmp (++s2, "zllo", 6) >= 0 || s2 != s1+1)
67 abort();
68 s2 = s1;
69 if (strncmp ("zllo", ++s2, 6) <= 0 || s2 != s1+1)
70 abort();
72 s2 = s1;
73 if (strncmp (++s2, "allo", 3) <= 0 || s2 != s1+1)
74 abort();
75 s2 = s1;
76 if (strncmp ("allo", ++s2, 3) >= 0 || s2 != s1+1)
77 abort();
78 s2 = s1;
79 if (strncmp (++s2, "allo", 4) <= 0 || s2 != s1+1)
80 abort();
81 s2 = s1;
82 if (strncmp ("allo", ++s2, 4) >= 0 || s2 != s1+1)
83 abort();
84 s2 = s1;
85 if (strncmp (++s2, "allo", 5) <= 0 || s2 != s1+1)
86 abort();
87 s2 = s1;
88 if (strncmp ("allo", ++s2, 5) >= 0 || s2 != s1+1)
89 abort();
90 s2 = s1;
91 if (strncmp (++s2, "allo", 6) <= 0 || s2 != s1+1)
92 abort();
93 s2 = s1;
94 if (strncmp ("allo", ++s2, 6) >= 0 || s2 != s1+1)
95 abort();
97 s2 = s1; n = 2; x = 1;
98 if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 3)
99 abort();
100 s2 = s1; n = 2; x = 1;
101 if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 3)
102 abort();
103 s2 = s1; n = 3; x = 1;
104 if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 4)
105 abort();
106 s2 = s1; n = 3; x = 1;
107 if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 4)
108 abort();
109 s2 = s1; n = 4; x = 1;
110 if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 5)
111 abort();
112 s2 = s1; n = 4; x = 1;
113 if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 5)
114 abort();
115 s2 = s1; n = 5; x = 1;
116 if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 6)
117 abort();
118 s2 = s1; n = 5; x = 1;
119 if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 6)
120 abort();
122 s2 = s1; n = 2;
123 if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 3)
124 abort();
125 s2 = s1; n = 2; x = 1;
126 if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 3)
127 abort();
128 s2 = s1; n = 3; x = 1;
129 if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 4)
130 abort();
131 s2 = s1; n = 3; x = 1;
132 if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 4)
133 abort();
134 s2 = s1; n = 4; x = 1;
135 if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 5)
136 abort();
137 s2 = s1; n = 4; x = 1;
138 if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 5)
139 abort();
140 s2 = s1; n = 5; x = 1;
141 if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 6)
142 abort();
143 s2 = s1; n = 5; x = 1;
144 if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 6)
145 abort();
147 s2 = s1; n = 2;
148 if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 3)
149 abort();
150 s2 = s1; n = 2; x = 1;
151 if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 3)
152 abort();
153 s2 = s1; n = 3; x = 1;
154 if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 4)
155 abort();
156 s2 = s1; n = 3; x = 1;
157 if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 4)
158 abort();
159 s2 = s1; n = 4; x = 1;
160 if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 5)
161 abort();
162 s2 = s1; n = 4; x = 1;
163 if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 5)
164 abort();
165 s2 = s1; n = 5; x = 1;
166 if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 6)
167 abort();
168 s2 = s1; n = 5; x = 1;
169 if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 6)
170 abort();
172 #endif