================
@@ -621,17 +660,34 @@ void CIRRecordLowering::accumulateFields() {
       // problem with taking the address of one of these, so it is in practice
       // not a horrifyingly problematic issue.
       assert(!cir::MissingFeatures::noUniqueAddressLayout());
+      // Dropping the field leaves no member to mark, so its bytes read as
+      // padding.  That is only sound when the field carries no ABI data
+      // either, which isEmptyFieldForLayout does not guarantee.  Report the
+      // gap rather than claim an emptiness the record does not have.  The base
+      // subobject lowering sees the same field, so only the complete object
+      // reports it.
+      if (!isEmptyFieldForABI(astContext, *field)) {
+        if (!nonVirtualBaseType)
+          cirGenTypes.getCGModule().errorNYI(
+              field->getSourceRange(),
+              "[[no_unique_address]] field that is empty for layout but holds "
+              "data for the ABI");
+        droppedFieldHoldingData = true;
----------------
adams381 wrote:

I've deleted it. Deleting it on its own trips the assert on the NYI test, since 
layout still finishes with a bad state after `errorNYI`.  Both asserts now 
permit `cgm.getDiags().hasErrorOccurred()` instead. That covers any future NYI 
in record lowering rather than only this one.

https://github.com/llvm/llvm-project/pull/215175
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to