================ @@ -1053,16 +1072,23 @@ void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity, if (pathContainsInit(Path)) return false; - SemaRef.Diag(DiagLoc, diag::warn_dangling_variable) - << RK << !Entity.getParent() - << ExtendingEntity->getDecl()->isImplicit() - << ExtendingEntity->getDecl() << Init->isGLValue() << DiagRange; + if (InitEntity) { + SemaRef.Diag(DiagLoc, diag::warn_dangling_variable) + << RK << !InitEntity->getParent() + << ExtendingEntity->getDecl()->isImplicit() + << ExtendingEntity->getDecl() << Init->isGLValue() << DiagRange; + } else { + SemaRef.Diag(DiagLoc, diag::warn_dangling_pointer_assignment) + << AEntity->LHS << DiagRange; + } break; } break; } case LK_MemInitializer: { + assert(InitEntity && "Expect only on initializing the entity"); + ---------------- usx95 wrote:
nit: Replace uses of `isa<MaterializeTemporaryExpr>(L)` with already computed `MTE`. Feel free to do this in a separate patch since this is not related. https://github.com/llvm/llvm-project/pull/96475 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits