1 // RUN: %clang_cc1 -fsyntax-only -verify %s
5 a
= (int *) __builtin_assume_aligned(a
, z
+ 1); // expected-error {{requested alignment is not a power of 2}}
10 test9
<42>(a
); // expected-note {{in instantiation of function template specialization 'test9<42>' requested here}}
14 int test10(int *a
, T z
) {
15 a
= (int *) __builtin_assume_aligned(a
, z
+ 1); // expected-error {{must be a constant integer}}
20 return test10(a
, 42); // expected-note {{in instantiation of function template specialization 'test10<int>' requested here}}
24 void *atest() __attribute__((assume_aligned(q
))); // expected-error {{requested alignment is not a power of 2}}
26 template <int q
, int o
>
27 void *atest2() __attribute__((assume_aligned(q
, o
))); // expected-error {{requested alignment is not a power of 2}}
30 atest
<31>(); // expected-note {{in instantiation of function template specialization 'atest<31>' requested here}}
33 atest2
<31, 5>(); // expected-note {{in instantiation of function template specialization 'atest2<31, 5>' requested here}}
37 // expected-error@+1 {{invalid application of 'sizeof' to a function type}}
38 template<typename T
> __attribute__((assume_aligned(sizeof(int(T()))))) T
*f();
40 void *p
= f
<void>(); // expected-note {{in instantiation of function template specialization 'f<void>' requested here}}
43 // expected-error@+1 {{functional-style cast from 'void' to 'int' is not allowed}}
44 template<typename T
> __attribute__((assume_aligned(sizeof((int(T())))))) T
*g();
46 void *p
= g
<void>(); // expected-note {{in instantiation of function template specialization 'g<void>' requested here}}
49 template <typename T
, int o
>
50 T
*atest3() __attribute__((assume_aligned(31, o
))); // expected-error {{requested alignment is not a power of 2}}
52 template <typename T
, int o
>
53 T
*atest4() __attribute__((assume_aligned(32, o
)));
60 // expected-warning@+1 {{'assume_aligned' attribute only applies to Objective-C methods and functions}}
61 class __attribute__((assume_aligned(32))) x
{
65 // expected-warning@+1 {{'assume_aligned' attribute only applies to return values that are pointers or references}}
66 x
foo() __attribute__((assume_aligned(32)));
69 static const int x
= 32;
73 static const int x
= 64;
77 static const int x
= 63;
81 void *atest5() __attribute__((assume_aligned(X::x
))); // expected-error {{requested alignment is not a power of 2}}
85 atest5
<s3
>(); // expected-note {{in instantiation of function template specialization 'atest5<s3>' requested here}}