1 // RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -verify %s
2 // RUN: not %clang_cc1 -std=gnu++11 -ast-dump %s | FileCheck %s
4 namespace attribute_aligned
{
7 char c
[1] __attribute__((__aligned__((N
)))); // expected-error {{alignment is not a power of 2}}
10 template <bool X
> struct check
{
11 int check_failed
[X
? 1 : -1]; // expected-error {{array with a negative size}}
14 template <int N
> struct check_alignment
{
15 typedef check
<N
== sizeof(X
<N
>)> t
; // expected-note {{in instantiation}}
18 check_alignment
<1>::t c1
;
19 check_alignment
<2>::t c2
;
20 check_alignment
<3>::t c3
; // expected-note 2 {{in instantiation}}
21 check_alignment
<4>::t c4
;
23 template<unsigned Size
, unsigned Align
>
24 class my_aligned_storage
26 __attribute__((aligned(Align
))) char storage
[Size
];
33 static_assert(sizeof(t
) == sizeof(T
), "my_aligned_storage size wrong");
34 static_assert(alignof(t
) == alignof(T
), "my_aligned_storage align wrong"); // expected-warning{{'alignof' applied to an expression is a GNU extension}}
38 my_aligned_storage
<sizeof(T
), alignof(T
)> t
;
45 extern const void *CFRetain(const void *ref
);
47 template<typename T
> __attribute__((cf_returns_retained
))
48 inline T
WBCFRetain(T aValue
) { return aValue
? (T
)CFRetain(aValue
) : (T
)0; }
51 extern void CFRelease(const void *ref
);
54 inline void WBCFRelease(__attribute__((cf_consumed
)) T aValue
) { if(aValue
) CFRelease(aValue
); }
57 // CHECK: FunctionTemplateDecl {{.*}} HasAnnotations
58 // CHECK: AnnotateAttr {{.*}} "ANNOTATE_FOO"
59 // CHECK: AnnotateAttr {{.*}} "ANNOTATE_BAR"
60 // CHECK: FunctionDecl {{.*}} HasAnnotations
61 // CHECK: TemplateArgument type 'int'
62 // CHECK: AnnotateAttr {{.*}} "ANNOTATE_FOO"
63 // CHECK: AnnotateAttr {{.*}} "ANNOTATE_BAR"
64 template<typename T
> [[clang::annotate("ANNOTATE_FOO"), clang::annotate("ANNOTATE_BAR")]] void HasAnnotations();
65 void UseAnnotations() { HasAnnotations
<int>(); }