Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / override-layout.cpp
blob07cd31580726e36c25aa3ad2ca0fbeac87452ea9
1 // RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.layouts
2 // RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.before
3 // RUN: %clang_cc1 %std_cxx98-14 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
4 // RUN: diff -u %t.before %t.after
5 // RUN: FileCheck --check-prefixes=CHECK,PRE17 %s < %t.after
7 // RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.layouts
8 // RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.before
9 // RUN: %clang_cc1 -std=c++17 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
10 // RUN: diff -u %t.before %t.after
11 // RUN: FileCheck --check-prefixes=CHECK,CXX17 %s < %t.after
13 // CXX17: Type: struct X6
15 // If not explicitly disabled, set PACKED to the packed attribute.
16 #ifndef PACKED
17 # define PACKED __attribute__((packed))
18 #endif
20 struct Empty1 { };
21 struct Empty2 { };
23 // CHECK: Type: struct X0
24 struct X0 : public Empty1 {
25 int x[6] PACKED;
28 // CHECK: Type: struct X1
29 struct X1 : public X0, public Empty2 {
30 char x[13];
31 struct X0 y;
32 } PACKED;
34 // CHECK: Type: struct X2
35 struct PACKED X2 : public X1, public X0, public Empty1 {
36 short x;
37 int y;
40 // CHECK: Type: struct X3
41 struct PACKED X3 : virtual public X1, public X0 {
42 short x;
43 int y;
46 // CHECK: Type: struct X4
47 struct PACKED X4 {
48 unsigned int a : 1;
49 unsigned int b : 1;
50 unsigned int c : 1;
51 unsigned int d : 1;
52 unsigned int e : 1;
53 unsigned int f : 1;
54 unsigned int g : 1;
55 unsigned int h : 1;
56 unsigned int i : 1;
57 unsigned int j : 1;
58 unsigned int k : 1;
59 unsigned int l : 1;
60 unsigned int m : 1;
61 unsigned int n : 1;
62 X4();
65 // CHECK: Type: struct X5
66 struct PACKED X5 {
67 union {
68 long a;
69 long b;
71 short l;
72 short r;
75 // PRE17: Type: struct X6
76 struct __attribute__((aligned(16))) X6 {
77 int x;
78 int y;
79 virtual ~X6();
82 // PRE17: Type: struct X7
83 struct X7 {
84 int z;
87 // PRE17: Type: struct X8
88 struct X8 : X6, virtual X7 {
89 char c;
92 void use_structs() {
93 X0 x0s[sizeof(X0)];
94 X1 x1s[sizeof(X1)];
95 X2 x2s[sizeof(X2)];
96 X3 x3s[sizeof(X3)];
97 X4 x4s[sizeof(X4)];
98 X5 x5s[sizeof(X5)];
99 X6 x6s[sizeof(X6)];
100 X7 x7s[sizeof(X7)];
101 X8 x8s[sizeof(X8)];
102 x4s[1].a = 1;
103 x5s[1].a = 17;