llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Including unions, where this is more important. --- Full diff: https://github.com/llvm/llvm-project/pull/102749.diff 2 Files Affected: - (modified) clang/lib/AST/Interp/Compiler.cpp (+3) - (modified) clang/test/AST/Interp/unions.cpp (+8) ``````````diff diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 6c4d607706c6b..1fa7a944448fb 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -3356,6 +3356,9 @@ bool Compiler<Emitter>::visitZeroRecordInitializer(const Record *R, assert(R); // Fields for (const Record::Field &Field : R->fields()) { + if (Field.Decl->isUnnamedBitField()) + continue; + const Descriptor *D = Field.Desc; if (D->isPrimitive()) { QualType QT = D->getType(); diff --git a/clang/test/AST/Interp/unions.cpp b/clang/test/AST/Interp/unions.cpp index 6f6bc3d6891b4..1f52950b1e09b 100644 --- a/clang/test/AST/Interp/unions.cpp +++ b/clang/test/AST/Interp/unions.cpp @@ -297,5 +297,13 @@ namespace Zeroing { static_assert(u6.a[4] == 0, ""); static_assert(u6.b == 0, ""); // both-error {{not an integral constant expression}} \ // both-note {{read of member 'b' of union with active member 'a'}} + + union UnionWithUnnamedBitfield { + int : 3; + int n; + }; + static_assert(UnionWithUnnamedBitfield().n == 0, ""); + static_assert(UnionWithUnnamedBitfield{}.n == 0, ""); + static_assert(UnionWithUnnamedBitfield{1}.n == 1, ""); } #endif `````````` </details> https://github.com/llvm/llvm-project/pull/102749 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits