================
@@ -1016,6 +1016,28 @@ class TrivialFunctionAnalysisVisitor
(CtorDecl->isMoveConstructor() &&
RD->hasTrivialMoveConstructor()))
return true;
+ // A defaulted default constructor that nothing has used yet has no
+ // definition, so decide from the initializers it would run.
+ if (CtorDecl->isDefaultConstructor() && !CtorDecl->isDeleted() &&
+ !CtorDecl->doesThisDeclarationHaveABody() &&
+ RD->hasDefinition()) {
----------------
rniwa wrote:
Oh, `RD->hasDefinition()` is for the class, not the constructor. But it's
always true here so I removed that redundant check.
Note that the constructor really has no body here. Whether the warning was
emitted depended on whether something else in the translation unit happened to
use the constructor. Once it's used, Sema will build the body for it and
`doesThisDeclarationHaveABody()` becomes `true` and we successfully conclude
that the body is "trivial".
https://github.com/llvm/llvm-project/pull/241102
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits