[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 28 09:12:02 PDT 2025
================
@@ -1341,6 +1342,13 @@ checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
}
if (IsGslPtrValueFromGslTempOwner && DiagLoc.isValid()) {
+
+ if (SemaRef.getLangOpts().CPlusPlus23) {
+ if (const VarDecl *VD = cast<VarDecl>(InitEntity->getDecl());
----------------
yronglin wrote:
```suggestion
if (const VarDecl *VD = dyn_cast_if_present<VarDecl>(InitEntity->getDecl());
```
https://github.com/llvm/llvm-project/pull/145164
More information about the cfe-commits
mailing list