[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / builtin-assume-aligned.c
blob3dfe7955af21a54804e437c461b4186238157ca7
1 // RUN: %clang_cc1 -DSIZE_T_64 -fsyntax-only -Wno-strict-prototypes -triple x86_64-linux -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -Wno-strict-prototypes -triple i386-freebsd -verify %s
4 // __builtin_assume_aligned's second parameter is size_t, which may be 32 bits,
5 // so test differently when size_t is 32 bits and when it is 64 bits.
7 int test1(int *a) {
8 a = __builtin_assume_aligned(a, 32, 0ull);
9 return a[0];
12 int test2(int *a) {
13 a = __builtin_assume_aligned(a, 32, 0);
14 return a[0];
17 int test3(int *a) {
18 a = __builtin_assume_aligned(a, 32);
19 return a[0];
22 int test4(int *a) {
23 a = __builtin_assume_aligned(a, -32); // expected-error {{requested alignment is not a power of 2}}
24 return a[0];
27 int test5(int *a, unsigned *b) {
28 a = __builtin_assume_aligned(a, 32, b); // expected-warning {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
29 return a[0];
32 int test6(int *a) {
33 a = __builtin_assume_aligned(a, 32, 0, 0); // expected-error {{too many arguments to function call, expected at most 3, have 4}}
34 return a[0];
37 int test7(int *a) {
38 a = __builtin_assume_aligned(a, 31); // expected-error {{requested alignment is not a power of 2}}
39 return a[0];
42 int test8(int *a, int j) {
43 a = __builtin_assume_aligned(a, j); // expected-error {{must be a constant integer}}
44 return a[0];
47 int test9(int *a) {
48 a = __builtin_assume_aligned(a, 1ULL << 31); // no-warning
49 return a[0];
52 #ifdef SIZE_T_64
53 int test10(int *a) {
54 a = __builtin_assume_aligned(a, 1ULL << 63); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
55 return a[0];
58 int test11(int *a) {
59 a = __builtin_assume_aligned(a, 1ULL << 32); // no-warning
60 return a[0];
63 int test12(int *a) {
64 a = __builtin_assume_aligned(a, 1ULL << 33); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
65 return a[0];
67 #endif
69 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
70 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
71 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
72 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(8589934592))); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
74 int j __attribute__((assume_aligned(8))); // expected-warning {{'assume_aligned' attribute only applies to Objective-C methods and functions}}
75 void *test_no_fn_proto() __attribute__((assume_aligned(32))); // no-warning
76 void *test_with_fn_proto(void) __attribute__((assume_aligned(128))); // no-warning
78 void *test_no_fn_proto() __attribute__((assume_aligned(31))); // expected-error {{requested alignment is not a power of 2}}
79 void *test_no_fn_proto() __attribute__((assume_aligned(32, 73))); // no-warning
81 void *test_no_fn_proto() __attribute__((assume_aligned)); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
82 void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
83 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}