Index: clang/include/clang/AST/NonTrivialTypeVisitor.h =================================================================== --- clang/include/clang/AST/NonTrivialTypeVisitor.h +++ clang/include/clang/AST/NonTrivialTypeVisitor.h @@ -1,4 +1,4 @@ -//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ --*-===// +//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp =================================================================== --- clang/lib/CodeGen/CGNonTrivialStruct.cpp +++ clang/lib/CodeGen/CGNonTrivialStruct.cpp @@ -543,6 +543,10 @@ std::array
Addrs) { LValue DstLV, SrcLV; if (FD) { + // No need to copy zero-length bit-fields. + if (FD->isZeroLengthBitField(this->CGF->getContext())) + return; + QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0); llvm::PointerType *PtrTy = this->CGF->ConvertType(RT)->getPointerTo(); Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset); Index: clang/test/CodeGenObjC/strong-in-c-struct.m =================================================================== --- clang/test/CodeGenObjC/strong-in-c-struct.m +++ clang/test/CodeGenObjC/strong-in-c-struct.m @@ -887,4 +887,14 @@ func(0); } +struct ZeroBitfield { + int : 0; + id strong; +}; + +void test_zero_bitfield() { + struct ZeroBitfield volatile a, b; + a = b; +} + #endif /* USESTRUCT */