114 lines · c
1// RUN: %clang_cc1 -fsyntax-only -DERR -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=vec-elem-size3// RUN: %clang_cc1 -fsyntax-only -DEXT -DERR -verify %s4// RUN: %clang_cc1 -fsyntax-only -DEXT -verify %s -Wno-error=vec-elem-size5 6#ifdef EXT7typedef __attribute__((__ext_vector_type__(8))) char vector_char8;8typedef __attribute__((__ext_vector_type__(8))) short vector_short8;9typedef __attribute__((__ext_vector_type__(8))) int vector_int8;10typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;11typedef __attribute__((__ext_vector_type__(8))) unsigned short vector_ushort8;12typedef __attribute__((__ext_vector_type__(8))) unsigned int vector_uint8;13typedef __attribute__((__ext_vector_type__(4))) char vector_char4;14typedef __attribute__((__ext_vector_type__(4))) short vector_short4;15typedef __attribute__((__ext_vector_type__(4))) int vector_int4;16typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4;17typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4;18typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4;19#else20typedef __attribute__((vector_size(8))) char vector_char8;21typedef __attribute__((vector_size(16))) short vector_short8;22typedef __attribute__((vector_size(32))) int vector_int8;23typedef __attribute__((vector_size(8))) unsigned char vector_uchar8;24typedef __attribute__((vector_size(16))) unsigned short vector_ushort8;25typedef __attribute__((vector_size(32))) unsigned int vector_uint8;26typedef __attribute__((vector_size(4))) char vector_char4;27typedef __attribute__((vector_size(4))) short vector_short4;28typedef __attribute__((vector_size(16))) int vector_int4;29typedef __attribute__((vector_size(4))) unsigned char vector_uchar4;30typedef __attribute__((vector_size(8))) unsigned short vector_ushort4;31typedef __attribute__((vector_size(16))) unsigned int vector_uint4;32#endif33 34char c;35short s;36int i;37unsigned char uc;38unsigned short us;39unsigned int ui;40vector_char8 vc8;41vector_short8 vs8;42vector_int8 vi8;43vector_uchar8 vuc8;44vector_ushort8 vus8;45vector_uint8 vui8;46vector_char4 vc4;47vector_short4 vs4;48vector_int4 vi4;49vector_uchar4 vuc4;50vector_ushort4 vus4;51vector_uint4 vui4;52 53void foo(void) {54 vc8 = 1 << vc8;55 vuc8 = 1 << vuc8;56 vi8 = 1 << vi8;57 vui8 = 1 << vui8;58 vs8 = 1 << vs8;59 vus8 = 1 << vus8;60 61 vc8 = c << vc8;62 vuc8 = i << vuc8;63 vi8 = uc << vi8;64 vui8 = us << vui8;65 vs8 = ui << vs8;66 vus8 = 1 << vus8;67 68 vc8 = vc8 << c;69 vuc8 = vuc8 << uc;70 vs8 = vs8 << s;71 vus8 = vus8 << us;72 vi8 = vi8 << i;73 vui8 = vui8 << ui;74 75 vc8 = vc8 << i;76 vuc8 = vuc8 << i;77 vs8 = vs8 << i;78 vus8 = vus8 << i;79 vi8 = vi8 << i;80 vui8 = vui8 << i;81 82 vc8 = vc8 << vc8;83#ifdef ERR84 vi8 = vi8 << vuc8; // expected-error {{vector operands do not have the same elements sizes}}85 vuc8 = vuc8 << vi8; // expected-error {{vector operands do not have the same elements sizes}}86 vus8 = vus8 << vui8; // expected-error {{vector operands do not have the same elements sizes}}87 vui8 = vui8 << vs8; // expected-error {{vector operands do not have the same elements sizes}}88#else89 vi8 = vi8 << vuc8; // expected-warning {{vector operands do not have the same elements sizes}}90 vuc8 = vuc8 << vi8; // expected-warning {{vector operands do not have the same elements sizes}}91 vus8 = vus8 << vui8; // expected-warning {{vector operands do not have the same elements sizes}}92 vui8 = vui8 << vs8; // expected-warning {{vector operands do not have the same elements sizes}}93#endif94 95 vc8 <<= vc8;96#ifdef ERR97 vi8 <<= vuc8; // expected-error {{vector operands do not have the same elements sizes}}98 vuc8 <<= vi8; // expected-error {{vector operands do not have the same elements sizes}}99 vus8 <<= vui8; // expected-error {{vector operands do not have the same elements sizes}}100 vui8 <<= vs8; // expected-error {{vector operands do not have the same elements sizes}}101#else102 vi8 <<= vuc8; // expected-warning {{vector operands do not have the same elements sizes}}103 vuc8 <<= vi8; // expected-warning {{vector operands do not have the same elements sizes}}104 vus8 <<= vui8; // expected-warning {{vector operands do not have the same elements sizes}}105 vui8 <<= vs8; // expected-warning {{vector operands do not have the same elements sizes}}106#endif107 108 c <<= vc8; // expected-error {{assigning to 'char' from incompatible type}}109 i <<= vuc8; // expected-error {{assigning to 'int' from incompatible type}}110 uc <<= vi8; // expected-error {{assigning to 'unsigned char' from incompatible type}}111 us <<= vui8; // expected-error {{assigning to 'unsigned short' from incompatible type}}112 ui <<= vs8; // expected-error {{assigning to 'unsigned int' from incompatible type}}113}114