1 // TLS variable cannot be aligned to more than 32 bytes on PS4.
3 // RUN: %clang_cc1 -triple x86_64-scei-ps4 -std=c++17 -fsyntax-only -verify %s
7 struct non_aligned_struct
{
8 int some_data
[16]; // 64 bytes of stuff, non aligned.
12 struct __attribute__(( aligned(64) )) aligned_struct
{
13 int some_data
[12]; // 48 bytes of stuff, aligned to 64.
16 // A type with an aligned field.
17 struct struct_with_aligned_field
{
18 int some_aligned_data
[12] __attribute__(( aligned(64) )); // 48 bytes of stuff, aligned to 64.
23 struct templated_struct
{};
24 // expected-note@-1{{candidate template ignored: couldn't infer template argument ''}}
25 // expected-note@-2{{candidate function template not viable: requires 1 argument, but 0 were provided}}
27 // A typedef of the aligned struct.
28 typedef aligned_struct another_aligned_struct
;
30 // A typedef to redefine a non-aligned struct as aligned.
31 typedef __attribute__(( aligned(64) )) non_aligned_struct yet_another_aligned_struct
;
33 // Non aligned variable doesn't cause an error.
34 __thread non_aligned_struct foo
;
36 // Variable aligned because of its type should cause an error.
37 __thread aligned_struct bar
; // expected-error{{alignment (64) of thread-local variable}}
39 // Variable explicitly aligned in the declaration should cause an error.
40 __thread non_aligned_struct bar2
__attribute__(( aligned(64) )); // expected-error{{alignment (64) of thread-local variable}}
42 // Variable aligned because of one of its fields should cause an error.
43 __thread struct_with_aligned_field bar3
; // expected-error{{alignment (64) of thread-local variable}}
45 // Variable aligned because of typedef, first case.
46 __thread another_aligned_struct bar4
; // expected-error{{alignment (64) of thread-local variable}}
48 // Variable aligned because of typedef, second case.
49 __thread yet_another_aligned_struct bar5
; // expected-error{{alignment (64) of thread-local variable}}
51 // No crash for undeduced type.
52 __thread templated_struct bar6
; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'templated_struct'}}
56 return foo
.some_data
[0] + bar
.some_data
[1] + bar2
.some_data
[2] +
57 bar3
.some_aligned_data
[3] + bar4
.some_data
[4] +
61 template<class T
> struct templated_tls
{
63 T other_t
__attribute__(( aligned(64) ));
65 __thread templated_tls
<int> blah
; // expected-error{{alignment (64) of thread-local variable}}
69 struct alignas(64) B
{};
70 struct alignas(N
) C
{};
71 static inline void f() {
72 thread_local B b
; // expected-error{{alignment (64) of thread-local variable}}
73 thread_local C c
; // expected-error{{alignment (64) of thread-local variable}}
75 template<int J
> static inline thread_local
int b
alignas(J
) = J
; // expected-error{{alignment (64) of thread-local variable}}
76 static int __thread
__attribute__((aligned(N
))) x
; // expected-error{{alignment (64) of thread-local variable}}
80 // Verify alignment check where the alignment is a template parameter.
81 // The check is only performed during instantiation.
82 S
<64> s_instance
; // expected-note{{in instantiation of template class 'S<64>' requested here}}
84 // Verify alignment for dependent local variables.
85 S
<64>::f(); // expected-note{{in instantiation of member function 'S<64>::f' requested here}}
87 // Verify alignment check where a dependent type is involved.
88 // The check is (correctly) not performed on "t", but the check still is
89 // performed on the structure as a whole once it has been instantiated.
90 return blah
.other_t
* 2 + S
<64>::b
<64>; // expected-note{{in instantiation of static data member 'S<64>::b' requested here}}