brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 07cd315 Raw
105 lines · cpp
1// RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.layouts2// RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.before3// RUN: %clang_cc1 %std_cxx98-14 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after4// RUN: diff -u %t.before %t.after5// RUN: FileCheck --check-prefixes=CHECK,PRE17 %s < %t.after6 7// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.layouts8// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.before9// RUN: %clang_cc1 -std=c++17 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after10// RUN: diff -u %t.before %t.after11// RUN: FileCheck --check-prefixes=CHECK,CXX17 %s < %t.after12 13// CXX17: Type: struct X614 15// If not explicitly disabled, set PACKED to the packed attribute.16#ifndef PACKED17#  define PACKED __attribute__((packed))18#endif19 20struct Empty1 { };21struct Empty2 { };22 23// CHECK: Type: struct X024struct X0 : public Empty1 { 25  int x[6] PACKED; 26};27 28// CHECK: Type: struct X129struct X1 : public X0, public Empty2 { 30  char x[13]; 31  struct X0 y; 32} PACKED;33 34// CHECK: Type: struct X235struct PACKED X2 :  public X1, public X0, public Empty1 {36  short x;37  int y;38};39 40// CHECK: Type: struct X341struct PACKED X3 : virtual public X1, public X0 {42  short x;43  int y;44};45 46// CHECK: Type: struct X447struct 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();63};64 65// CHECK: Type: struct X566struct PACKED X5 {67  union {68    long a;69    long b;70  };71  short l;72  short r;73};74 75// PRE17: Type: struct X676struct __attribute__((aligned(16))) X6 {77  int x;78  int y;79  virtual ~X6();80};81 82// PRE17: Type: struct X783struct X7 {84  int z;85};86 87// PRE17: Type: struct X888struct X8 : X6, virtual X7 {89  char c;90};91 92void 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;104}105