1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -triple x86_64-unknown-unknown -verify %s
5 static const int test0
= __builtin_omp_required_simd_align(x
); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an expression, only type is allowed}}
6 static const int test1
= __builtin_omp_required_simd_align(decltype(S0::x
));
7 auto test2() -> char(&)[__builtin_omp_required_simd_align(decltype(x
))];
10 struct S1
; // expected-note 6 {{forward declaration}}
12 const int test3
= __builtin_omp_required_simd_align(decltype(s1
)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'decltype(s1)' (aka 'S1')}}
19 int test4
= __builtin_omp_required_simd_align(decltype(x
)); // ok
20 int test5
= __builtin_omp_required_simd_align(decltype(s
)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
23 const int test6
= __builtin_omp_required_simd_align(decltype(S2::x
));
24 const int test7
= __builtin_omp_required_simd_align(decltype(S2::s
)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
26 // Arguably, these should fail like the S1 cases do: the alignment of
27 // 's2.x' should depend on the alignment of both x-within-S2 and
28 // s2-within-S3 and thus require 'S3' to be complete. If we start
29 // doing the appropriate recursive walk to do that, we should make
30 // sure that these cases don't explode.
34 static const int test8
= __builtin_omp_required_simd_align(decltype(s2
.x
));
35 static const int test9
= __builtin_omp_required_simd_align(decltype(s2
.s
)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
36 auto test10() -> char(&)[__builtin_omp_required_simd_align(decltype(s2
.x
))];
37 static const int test11
= __builtin_omp_required_simd_align(decltype(S3::s2
.x
));
38 static const int test12
= __builtin_omp_required_simd_align(decltype(S3::s2
.s
)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
39 auto test13() -> char(&)[__builtin_omp_required_simd_align(decltype(s2
.x
))];
42 // Same reasoning as S3.
47 static const int test0
= __builtin_omp_required_simd_align(decltype(x
));
48 static const int test1
= __builtin_omp_required_simd_align(decltype(S0::x
));
49 auto test2() -> char(&)[__builtin_omp_required_simd_align(decltype(x
))];
52 // Regression test for asking for the alignment of a field within an invalid
55 S1 s
; // expected-error {{incomplete type}}
58 const int test8
= __builtin_omp_required_simd_align(decltype(S5::x
));
60 long long int test14
[2];
62 static_assert(__builtin_omp_required_simd_align(decltype(test14
)) == 16, "foo");
64 static_assert(__builtin_omp_required_simd_align(int[2]) == __builtin_omp_required_simd_align(int), ""); // ok
66 namespace __builtin_omp_required_simd_align_array_expr
{
67 alignas(32) extern int n
[2];
68 static_assert(__builtin_omp_required_simd_align(decltype(n
)) == 16, "");
70 template<int> struct S
{
73 template<int N
> int S
<N
>::a
[N
];
74 static_assert(__builtin_omp_required_simd_align(decltype(S
<1>::a
)) == __builtin_omp_required_simd_align(int), "");
75 static_assert(__builtin_omp_required_simd_align(decltype(S
<1128>::a
)) == __builtin_omp_required_simd_align(int), "");
78 template <typename T
> void n(T
) {
80 char k
[__builtin_omp_required_simd_align(decltype(T1
))];
81 static_assert(sizeof(k
) == __builtin_omp_required_simd_align(long long), "");
83 template void n(long long);