File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -655,11 +655,14 @@ void CIRRecordLowering::lowerUnion() {
655655 // locate the "most appropriate" storage type.
656656 for (const FieldDecl *field : recordDecl->fields ()) {
657657 mlir::Type fieldType;
658- if (field->isBitField ())
659- cirGenTypes.getCGModule ().errorNYI (recordDecl->getSourceRange (),
660- " bitfields in lowerUnion" );
661- else
658+ if (field->isBitField ()) {
659+ if (field->isZeroLengthBitField ())
660+ continue ;
661+ fieldType = getBitfieldStorageType (field->getBitWidthValue ());
662+ setBitFieldInfo (field, CharUnits::Zero (), fieldType);
663+ } else {
662664 fieldType = getStorageType (field);
665+ }
663666
664667 // This maps a field to its index. For unions, the index is always 0.
665668 fieldIdxMap[field->getCanonicalDecl ()] = 0 ;
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+ // RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
3+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
4+ // RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM
5+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
6+ // RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
7+
8+ typedef union {
9+ int x ;
10+ int y : 4 ;
11+ int z : 8 ;
12+ } demo ;
13+
14+ // CIR: !rec_demo = !cir.record<union "demo" {!s32i, !u8i, !u8i}>
15+ // LLVM: %union.demo = type { i32 }
16+ // OGCG: %union.demo = type { i32 }
17+ demo d ;
18+
19+
You can’t perform that action at this time.
0 commit comments