AggExprEmitter::VisitInitListExpr sanity checks that an empty union is really
empty and not a semantic analysis failure. The assert is missing that we allow
anonymous structs as a GNU extension. I have updated the assert to take that into account.
This fixes: https://github.com/llvm/llvm-project/issues/58800
Differential Revision: https://reviews.llvm.org/D139261
- 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// 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;
}
}
} 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