1 // RUN: %clang_cc1 -ast-dump -verify -x c %s | FileCheck -check-prefix=CHECK-C %s
2 // RUN: %clang_cc1 -ast-dump -x c++ -std=c++11 %s | FileCheck %s --check-prefixes CHECK-C,CHECK-CPP
4 // expected-no-diagnostics
7 // CHECK-C: FunctionDecl{{.*}}code_align 'void ()'
10 // CHECK-C: AttributedStmt
11 // CHECK-C-NEXT: CodeAlignAttr
12 // CHECK-C-NEXT: ConstantExpr{{.*}}'int'
13 // CHECK-C-NEXT: value: Int 16
14 // CHECK-C-NEXT: IntegerLiteral{{.*}}16{{$}}
15 [[clang::code_align(16)]] for (int p
= 0; p
< 128; ++p
) {
19 // CHECK-C: AttributedStmt
20 // CHECK-C-NEXT: CodeAlignAttr
21 // CHECK-C-NEXT: ConstantExpr{{.*}}'int'
22 // CHECK-C-NEXT: value: Int 4
23 // CHECK-C-NEXT: IntegerLiteral{{.*}}4{{$}}
25 [[clang::code_align(4)]] while (i
< 30) {
29 // CHECK-C: AttributedStmt
30 // CHECK-C-NEXT: CodeAlignAttr
31 // CHECK-C-NEXT: ConstantExpr{{.*}}'int'
32 // CHECK-C-NEXT: value: Int 32
33 // CHECK-C-NEXT: IntegerLiteral{{.*}}32{{$}}
34 for (int i
= 0; i
< 128; ++i
) {
35 [[clang::code_align(32)]] for (int j
= 0; j
< 128; ++j
) {
40 // CHECK-C: AttributedStmt
41 // CHECK-C-NEXT: CodeAlignAttr
42 // CHECK-C-NEXT: ConstantExpr{{.*}}'int'
43 // CHECK-C-NEXT: value: Int 64
44 // CHECK-C-NEXT: IntegerLiteral{{.*}}64{{$}}
45 [[clang::code_align(64)]]
46 for(int I
=0; I
<128; ++I
) { bar(I
); }
48 // CHECK-C: AttributedStmt
49 // CHECK-C-NEXT: CodeAlignAttr
50 // CHECK-C-NEXT: ConstantExpr{{.*}}'int'
51 // CHECK-C-NEXT: value: Int 4
52 // CHECK-C-NEXT: IntegerLiteral{{.*}}4{{$}}
54 [[clang::code_align(4)]] do {
59 #if __cplusplus >= 201103L
60 //CHECK-CPP: FunctionDecl{{.*}}used code_align_cpp 'void ()' implicit_instantiation
61 template <int A
, int B
>
62 void code_align_cpp() {
64 // CHECK-CPP: AttributedStmt
65 // CHECK-CPP-NEXT: CodeAlignAttr
66 // CHECK-CPP-NEXT: ConstantExpr{{.*}}'int'
67 // CHECK-CPP-NEXT: value: Int 32
68 // CHECK-CPP-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'int'
69 // CHECK-CPP-NEXT: NonTypeTemplateParmDecl{{.*}}referenced 'int' depth 0 index 0 A
70 // CHECK-CPP-NEXT: IntegerLiteral{{.*}}32{{$}}
71 [[clang::code_align(A
)]] for (int i
= 0; i
!= 10; ++i
)
74 // CHECK-CPP: AttributedStmt
75 // CHECK-CPP-NEXT: CodeAlignAttr
76 // CHECK-CPP-NEXT: ConstantExpr{{.*}}'int'
77 // CHECK-CPP-NEXT: value: Int 4
78 // CHECK-CPP-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'int'
79 // CHECK-CPP-NEXT: NonTypeTemplateParmDecl{{.*}}referenced 'int' depth 0 index 1 B
80 // CHECK-CPP-NEXT: IntegerLiteral{{.*}}4{{$}}
81 int c
[] = {0, 1, 2, 3, 4, 5};
82 [[clang::code_align(B
)]] for (int n
: c
) { n
*= 2; }
86 code_align_cpp
<32, 4>();