1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only %s 2>/dev/null \ 2 // RUN: | FileCheck %s -check-prefix CHECK 3 4 // Before PR45420, we would only find the alignment on this record. Afterwards, 5 // we can see the alignment on the typedef through the array type. 6 // FIXME: What about other type sugar, like _Atomic? This would only matter in a 7 // packed struct context. 8 struct __declspec(align(16)) AlignedStruct { int x; }; 9 typedef int __declspec(align(16)) AlignedInt; 10 11 #define CHECK_SIZE(X, Align) \ 12 _Static_assert(__alignof(struct X) == Align, "should be aligned"); 13 14 #pragma pack(push, 2) 15 16 struct A { 17 struct AlignedStruct a[1]; 18 }; 19 CHECK_SIZE(A, 16); 20 21 struct B { 22 char b; 23 AlignedInt a[1]; 24 }; 25 CHECK_SIZE(B, 16); 26 27 struct C { 28 char b; 29 AlignedInt a[]; 30 }; 31 CHECK_SIZE(C, 16); 32 33 // CHECK: *** Dumping AST Record Layout 34 // CHECK-NEXT: 0 | struct AlignedStruct 35 // CHECK-NEXT: 0 | int x 36 // CHECK-NEXT: | [sizeof=16, align=16] 37 // CHECK: *** Dumping AST Record Layout 38 // CHECK-NEXT: 0 | struct A 39 // CHECK-NEXT: 0 | struct AlignedStruct[1] a 40 // CHECK-NEXT: | [sizeof=16, align=16] 41 // CHECK: *** Dumping AST Record Layout 42 // CHECK-NEXT: 0 | struct B 43 // CHECK-NEXT: 0 | char b 44 // CHECK-NEXT: 16 | AlignedInt[1] a 45 // CHECK-NEXT: | [sizeof=32, align=16] 46 // CHECK: *** Dumping AST Record Layout 47 // CHECK-NEXT: 0 | struct C 48 // CHECK-NEXT: 0 | char b 49 // CHECK-NEXT: 16 | AlignedInt[] a 50 // CHECK-NEXT: | [sizeof=16, align=16] 51 52 #pragma pack(pop) 53 54