[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / SemaCXX / vector-bool.cpp
blob1b83a20999cb2b8c22d9d6afee87fcb73c8c9a21
1 // RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++17
2 // Note that this test depends on the size of long-long to be different from
3 // int, so it specifies a triple.
5 using FourShorts = short __attribute__((__vector_size__(8)));
6 using TwoInts = int __attribute__((__vector_size__(8)));
7 using EightInts = int __attribute__((__vector_size__(32)));
8 using TwoUInts = unsigned __attribute__((__vector_size__(8)));
9 using FourInts = int __attribute__((__vector_size__(16)));
10 using FourUInts = unsigned __attribute__((__vector_size__(16)));
11 using TwoLongLong = long long __attribute__((__vector_size__(16)));
12 using FourLongLong = long long __attribute__((__vector_size__(32)));
13 using TwoFloats = float __attribute__((__vector_size__(8)));
14 using FourFloats = float __attribute__((__vector_size__(16)));
15 using TwoDoubles = double __attribute__((__vector_size__(16)));
16 using FourDoubles = double __attribute__((__vector_size__(32)));
17 using EightBools = bool __attribute__((ext_vector_type(8)));
19 EightInts eight_ints;
20 EightBools eight_bools;
21 EightBools other_eight_bools;
22 bool one_bool;
24 // Check the rules of the LHS/RHS of the conditional operator.
25 void Operations() {
26 // Legal binary
27 // (void)(eight_bools | other_eight_bools);
28 // (void)(eight_bools & other_eight_bools);
29 // (void)(eight_bools ^ other_eight_bools);
30 // (void)(~eight_bools);
31 // (void)(!eight_bools);
33 // // Legal comparison
34 // (void)(eight_bools == other_eight_bools);
35 // (void)(eight_bools != other_eight_bools);
36 // (void)(eight_bools < other_eight_bools);
37 // (void)(eight_bools <= other_eight_bools);
38 // (void)(eight_bools > other_eight_bools);
39 // (void)(eight_bools >= other_eight_bools);
41 // // Legal assignments
42 // (void)(eight_bools |= other_eight_bools);
43 // (void)(eight_bools &= other_eight_bools);
44 // (void)(eight_bools ^= other_eight_bools);
46 // Illegal operators
47 (void)(eight_bools || other_eight_bools); // expected-error@47 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
48 (void)(eight_bools && other_eight_bools); // expected-error@48 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
49 (void)(eight_bools + other_eight_bools); // expected-error@49 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
50 (void)(eight_bools - other_eight_bools); // expected-error@50 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
51 (void)(eight_bools * other_eight_bools); // expected-error@51 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
52 (void)(eight_bools << other_eight_bools); // expected-error@52 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
53 (void)(eight_bools >> other_eight_bools); // expected-error@53 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
54 (void)(eight_bools / other_eight_bools); // expected-error@54 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
55 (void)(eight_bools % other_eight_bools); // expected-error@55 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
57 // Illegal assignment
58 (void)(eight_bools += other_eight_bools); // expected-error@58 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
59 (void)(eight_bools -= other_eight_bools); // expected-error@59 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
60 (void)(eight_bools *= other_eight_bools); // expected-error@60 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
61 (void)(eight_bools <<= other_eight_bools); // expected-error@61 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
62 (void)(eight_bools >>= other_eight_bools); // expected-error@62 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
63 (void)(eight_bools /= other_eight_bools); // expected-error@63 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
64 (void)(eight_bools %= other_eight_bools); // expected-error@64 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightBools')}}
66 // Illegal in/decrements
67 (void)(eight_bools++); // expected-error@67 {{cannot increment value of type 'EightBools' (vector of 8 'bool' values)}}
68 (void)(++eight_bools); // expected-error@68 {{cannot increment value of type 'EightBools' (vector of 8 'bool' values)}}
69 (void)(eight_bools--); // expected-error@69 {{cannot decrement value of type 'EightBools' (vector of 8 'bool' values)}}
70 (void)(--eight_bools); // expected-error@70 {{cannot decrement value of type 'EightBools' (vector of 8 'bool' values)}}
72 // No implicit promotion
73 (void)(eight_bools + eight_ints); // expected-error@73 {{invalid operands to binary expression ('EightBools' (vector of 8 'bool' values) and 'EightInts' (vector of 8 'int' values))}}
74 (void)(eight_ints - eight_bools); // expected-error@74 {{invalid operands to binary expression ('EightInts' (vector of 8 'int' values) and 'EightBools' (vector of 8 'bool' values))}}
77 // Allow scalar-to-vector broadcast. Do not allow bool vector conversions.
78 void Conversions() {
79 (void)((long)eight_bools); // expected-error@79 {{C-style cast from vector 'EightBools' (vector of 8 'bool' values) to scalar 'long' of different size}}
80 (void)((EightBools) one_bool); // Scalar-to-vector broadcast.
81 (void)((char)eight_bools); // expected-error@81 {{C-style cast from vector 'EightBools' (vector of 8 'bool' values) to scalar 'char' of different size}}
84 void foo(const bool& X);
86 // Disallow element-wise access.
87 bool* ElementRefs() {
88 eight_bools.y = false; // expected-error@88 {{illegal vector component name ''y''}}
89 &eight_bools.z; // expected-error@89 {{illegal vector component name ''z''}}
90 foo(eight_bools.w); // expected-error@90 {{illegal vector component name ''w''}}
91 foo(eight_bools.wyx); // expected-error@91 {{illegal vector component name ''wyx''}}