76 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -mms-bitfields -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -mms-bitfields -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -mms-bitfields -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG7 8struct s1 {9 int f32 : 2;10 long long f64 : 30;11} s1;12 13// CIR-DAG: !rec_s1 = !cir.record<struct "s1" {!s32i, !s64i}>14// LLVM-DAG: %struct.s1 = type { i32, i64 }15// OGCG-DAG: %struct.s1 = type { i32, i64 }16 17struct s2 {18 int a : 24;19 char b;20 int c : 30;21} Clip;22 23// CIR-DAG: !rec_s2 = !cir.record<struct "s2" {!s32i, !s8i, !s32i}>24// LLVM-DAG: %struct.s2 = type { i32, i8, i32 }25// OGCG-DAG: %struct.s2 = type { i32, i8, i32 }26 27struct s3 {28 int a : 18;29 int : 0;30 int c : 14;31} zero_bit;32 33// CIR-DAG: !rec_s3 = !cir.record<struct "s3" {!s32i, !s32i}>34// LLVM-DAG: %struct.s3 = type { i32, i32 }35// OGCG-DAG: %struct.s3 = type { i32, i32 }36 37#pragma pack (push,1)38 39struct Inner {40 unsigned int A : 1;41 unsigned int B : 1;42 unsigned int C : 1;43 unsigned int D : 30;44} Inner;45 46#pragma pack (pop)47 48// CIR-DAG: !rec_Inner = !cir.record<struct "Inner" {!u32i, !u32i}>49// LLVM-DAG: %struct.Inner = type { i32, i32 }50// OGCG-DAG: %struct.Inner = type { i32, i32 }51 52#pragma pack(push, 1)53 54union HEADER {55 struct A {56 int : 3; // Bits 2:057 int a : 9; // Bits 11:358 int : 12; // Bits 23:1259 int b : 17; // Bits 40:2460 int : 7; // Bits 47:4161 int c : 4; // Bits 51:4862 int : 4; // Bits 55:5263 int d : 3; // Bits 58:5664 int : 5; // Bits 63:5965 } Bits;66} HEADER;67 68#pragma pack(pop)69 70// CIR-DAG: !rec_A = !cir.record<struct "A" {!s32i, !s32i, !s32i}>71// CIR-DAG: !rec_HEADER = !cir.record<union "HEADER" {!rec_A}>72// LLVM-DAG: %struct.A = type { i32, i32, i32 }73// LLVM-DAG: %union.HEADER = type { %struct.A }74// OGCG-DAG: %struct.A = type { i32, i32, i32 }75// OGCG-DAG: %union.HEADER = type { %struct.A }76