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.
8 a
= __builtin_assume_aligned(a
, 32, 0ull);
13 a
= __builtin_assume_aligned(a
, 32, 0);
18 a
= __builtin_assume_aligned(a
, 32);
23 a
= __builtin_assume_aligned(a
, -32); // expected-error {{requested alignment is not a power of 2}}
27 int test5(int *a
, unsigned *b
) {
28 a
= __builtin_assume_aligned(a
, 32, b
); // expected-error {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
33 a
= __builtin_assume_aligned(a
, 32, 0, 0); // expected-error {{too many arguments to function call, expected at most 3, have 4}}
38 a
= __builtin_assume_aligned(a
, 31); // expected-error {{requested alignment is not a power of 2}}
42 int test8(int *a
, int j
) {
43 a
= __builtin_assume_aligned(a
, j
); // expected-error {{must be a constant integer}}
48 a
= __builtin_assume_aligned(a
, 1ULL << 31); // no-warning
54 a
= __builtin_assume_aligned(a
, 1ULL << 63); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
59 a
= __builtin_assume_aligned(a
, 1ULL << 32); // no-warning
64 a
= __builtin_assume_aligned(a
, 1ULL << 33); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
70 a
= (int *)__builtin_assume_aligned(a
, 2 * 2.0); // expected-error {{argument to '__builtin_assume_aligned' must be a constant integer}}
74 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
75 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
76 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
77 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(8589934592))); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
79 int j
__attribute__((assume_aligned(8))); // expected-warning {{'assume_aligned' attribute only applies to Objective-C methods and functions}}
80 void *test_no_fn_proto() __attribute__((assume_aligned(32))); // no-warning
81 void *test_with_fn_proto(void) __attribute__((assume_aligned(128))); // no-warning
83 void *test_no_fn_proto() __attribute__((assume_aligned(31))); // expected-error {{requested alignment is not a power of 2}}
84 void *test_no_fn_proto() __attribute__((assume_aligned(32, 73))); // no-warning
86 void *test_no_fn_proto() __attribute__((assume_aligned
)); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
87 void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
88 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}