[Clang] NFC: Remove duplicated variable def in CheckLValueConstantExpression

This commit is contained in:
Corentin Jabot 2022-09-10 19:07:56 +02:00
parent 10edf88458
commit 0e8afddaa1
1 changed files with 3 additions and 5 deletions

View File

@ -2174,12 +2174,10 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
// assumed to be global here.
if (!IsGlobalLValue(Base)) {
if (Info.getLangOpts().CPlusPlus11) {
const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>();
Info.FFDiag(Loc, diag::note_constexpr_non_global, 1)
<< IsReferenceType << !Designator.Entries.empty()
<< !!VD << VD;
auto *VarD = dyn_cast_or_null<VarDecl>(VD);
<< IsReferenceType << !Designator.Entries.empty() << !!BaseVD
<< BaseVD;
auto *VarD = dyn_cast_or_null<VarDecl>(BaseVD);
if (VarD && VarD->isConstexpr()) {
// Non-static local constexpr variables have unintuitive semantics:
// constexpr int a = 1;