This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG475cc44a2cba: [Clang] Modify sanity check assert in AggExprEmitter::VisitInitListExpr to… (authored by shafik). Herald added a project: clang.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139261/new/ https://reviews.llvm.org/D139261 Files: clang/docs/ReleaseNotes.rst clang/lib/CodeGen/CGExprAgg.cpp clang/test/SemaCXX/anonymous-struct.cpp Index: clang/test/SemaCXX/anonymous-struct.cpp =================================================================== --- clang/test/SemaCXX/anonymous-struct.cpp +++ clang/test/SemaCXX/anonymous-struct.cpp @@ -189,3 +189,20 @@ } } A; // expected-note {{given name 'A' for linkage purposes by this typedef}} } + +#if __cplusplus > 201103L +namespace GH58800 { +struct A { + union { + struct { + float red = 0.0f; + }; + }; +}; + +A GetA() { + A result{}; + return result; +} +} +#endif Index: clang/lib/CodeGen/CGExprAgg.cpp =================================================================== --- clang/lib/CodeGen/CGExprAgg.cpp +++ clang/lib/CodeGen/CGExprAgg.cpp @@ -1724,7 +1724,7 @@ // Make sure that it's really an empty and not a failure of // semantic analysis. for (const auto *Field : record->fields()) - assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed"); + assert((Field->isUnnamedBitfield() || Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous class allowed"); #endif return; } Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -326,6 +326,9 @@ - Fix bug where constant evaluation treated a pointer to member that points to a weak member as never being null. Such comparisons are now treated as non-constant. +- Fix sanity check when value initializing an empty union so that it takes into + account anonymous structs which is a GNU extension. This fixes + `Issue 58800 <https://github.com/llvm/llvm-project/issues/58800>`_ Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Index: clang/test/SemaCXX/anonymous-struct.cpp =================================================================== --- clang/test/SemaCXX/anonymous-struct.cpp +++ clang/test/SemaCXX/anonymous-struct.cpp @@ -189,3 +189,20 @@ } } A; // expected-note {{given name 'A' for linkage purposes by this typedef}} } + +#if __cplusplus > 201103L +namespace GH58800 { +struct A { + union { + struct { + float red = 0.0f; + }; + }; +}; + +A GetA() { + A result{}; + return result; +} +} +#endif Index: clang/lib/CodeGen/CGExprAgg.cpp =================================================================== --- clang/lib/CodeGen/CGExprAgg.cpp +++ clang/lib/CodeGen/CGExprAgg.cpp @@ -1724,7 +1724,7 @@ // Make sure that it's really an empty and not a failure of // semantic analysis. for (const auto *Field : record->fields()) - assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed"); + assert((Field->isUnnamedBitfield() || Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous class allowed"); #endif return; } Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -326,6 +326,9 @@ - Fix bug where constant evaluation treated a pointer to member that points to a weak member as never being null. Such comparisons are now treated as non-constant. +- Fix sanity check when value initializing an empty union so that it takes into + account anonymous structs which is a GNU extension. This fixes + `Issue 58800 <https://github.com/llvm/llvm-project/issues/58800>`_ Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits