You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Valid: bool converts to int for second argument
112
112
(void)__builtin_stdc_rotate_left(ui, b);
113
-
(void)__builtin_stdc_rotate_left(ui, f);
114
-
(void)__builtin_stdc_rotate_left(ui, 1.5); // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.5 to 1}}
115
113
(void)__builtin_stdc_rotate_right(ui, b);
116
-
(void)__builtin_stdc_rotate_right(ui, f);
117
114
118
-
// Test implicit conversions for first argument
119
-
(void)__builtin_stdc_rotate_left(si, 1);
120
-
(void)__builtin_stdc_rotate_left(-5, 1);
121
-
(void)__builtin_stdc_rotate_right(3.0, 1.5); // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.5 to 1}}
115
+
// Valid: signed int is an integer type for second argument
116
+
(void)__builtin_stdc_rotate_left(ui, si);
117
+
(void)__builtin_stdc_rotate_right(ui, si);
118
+
}
119
+
120
+
voidtest_invalid_types(floatf, intsi) {
121
+
unsigned intui=5;
122
+
123
+
// Invalid: float is not an integer type for second argument
124
+
(void)__builtin_stdc_rotate_left(ui, f); // expected-error {{2nd argument must be a scalar integer type (was 'float')}}
125
+
(void)__builtin_stdc_rotate_left(ui, 1.5); // expected-error {{2nd argument must be a scalar integer type (was 'double')}}
126
+
(void)__builtin_stdc_rotate_right(ui, f); // expected-error {{2nd argument must be a scalar integer type (was 'float')}}
122
127
123
-
// Test narrowing conversion in assignment
124
-
unsigned_BitInt(17) rotated_odd=__builtin_stdc_rotate_left(0x1ABCD, 5); // expected-warning {{implicit conversion from 'unsigned int' to 'unsigned _BitInt(17)' changes value from 3504544 to 96672}}
125
-
(void)rotated_odd;
128
+
// Invalid: signed int is not unsigned for first argument
129
+
(void)__builtin_stdc_rotate_left(si, 1); // expected-error {{1st argument must be a scalar unsigned integer type (was 'int')}}
130
+
(void)__builtin_stdc_rotate_left(-5, 1); // expected-error {{1st argument must be a scalar unsigned integer type (was 'int')}}
131
+
(void)__builtin_stdc_rotate_right(3.0, 1); // expected-error {{1st argument must be a scalar unsigned integer type (was 'double')}}
auto result4 = __builtin_stdc_rotate_right(uw, RotateAmount::ROTATE_BY_4);
186
186
187
187
bool b = true;
188
-
float f = 3.7f;
189
188
auto result5 = __builtin_stdc_rotate_left(10U, b);
190
-
auto result6 = __builtin_stdc_rotate_left(10U, f);
191
-
auto result7 = __builtin_stdc_rotate_right(10U, 2.9f); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 2.9000001 to 2}}
192
189
}
193
190
194
-
voidtest_no_conversions() {
191
+
voidtest_invalid_types() {
192
+
float f = 3.7f;
193
+
auto result6 = __builtin_stdc_rotate_left(10U, f); // expected-error {{2nd argument must be a scalar integer type (was 'float')}}
194
+
auto result7 = __builtin_stdc_rotate_right(10U, 2.9f); // expected-error {{2nd argument must be a scalar integer type (was 'float')}}
195
+
195
196
NoConversion nc;
196
-
auto result1 = __builtin_stdc_rotate_left(5U, nc); // expected-error {{passing 'NoConversion' to parameter of incompatible type 'int'}} expected-error {{2nd argument must be a scalar signed integer type (was 'NoConversion')}}
197
+
auto result1 = __builtin_stdc_rotate_left(5U, nc); // expected-error {{2nd argument must be a scalar integer type (was 'NoConversion')}}
0 commit comments