[clang] [clang] [NFC] In GetDiagForGotoScopeDecl(), limit Init to inside the if condition (PR #116080)
Boaz Brickner via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 13 08:55:28 PST 2024
https://github.com/bricknerb created https://github.com/llvm/llvm-project/pull/116080
None
>From 3d3d273f849ed5cdf357d6c1ea7c34f76f51afeb Mon Sep 17 00:00:00 2001
From: Boaz Brickner <brickner at google.com>
Date: Wed, 13 Nov 2024 17:54:40 +0100
Subject: [PATCH] [clang] [NFC] In GetDiagForGotoScopeDecl(), limit Init to
inside the if condition
---
clang/lib/Sema/JumpDiagnostics.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 8c830769a969cd..d465599450e7ff 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -179,9 +179,9 @@ static ScopePair GetDiagForGotoScopeDecl(Sema &S, const Decl *D) {
}
}
- const Expr *Init = VD->getInit();
- if (S.Context.getLangOpts().CPlusPlus && VD->hasLocalStorage() && Init &&
- !Init->containsErrors()) {
+ if (const Expr *Init = VD->getInit(); S.Context.getLangOpts().CPlusPlus &&
+ VD->hasLocalStorage() && Init &&
+ !Init->containsErrors()) {
// C++11 [stmt.dcl]p3:
// A program that jumps from a point where a variable with automatic
// storage duration is not in scope to a point where it is in scope
More information about the cfe-commits
mailing list