[clang] [Clang] Implement diagnostics for why is_empty is false (PR #145044)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 23 08:26:08 PDT 2025
================
@@ -2285,6 +2286,68 @@ static void DiagnoseNonTriviallyCopyableReason(Sema &SemaRef,
SemaRef.Diag(D->getLocation(), diag::note_defined_here) << D;
}
+static void DiagnoseIsEmptyReason(Sema &S, SourceLocation Loc,
+ const CXXRecordDecl *D) {
+ // Non-static data members (ignore zero-width bitāfields).
+ for (auto *Field : D->fields()) {
+ if (Field->isBitField() && Field->getBitWidthValue() == 0)
----------------
AaronBallman wrote:
We should probably ensure we have tests for dependent values/types, along the lines of:
```
template <int N>
struct S {
int field : N;
};
S<0> s1; // Empty
S<1> s2; // Non-empty
```
https://github.com/llvm/llvm-project/pull/145044
More information about the cfe-commits
mailing list