Skip to content

Commit 5cb2ea5

Browse files
committed
[clang][Interp][NFC] Remove VarDecl requirement in diagnoseUnknownDecl()
We can call diagnoseNonConstVariable() for all ValueDecls just fine.
1 parent 11b97da commit 5cb2ea5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

clang/lib/AST/Interp/Interp.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,15 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
7676
} else {
7777
S.FFDiag(E);
7878
}
79-
} else if (const auto *VD = dyn_cast<VarDecl>(D)) {
80-
if (!VD->getType().isConstQualified()) {
81-
diagnoseNonConstVariable(S, OpPC, VD);
82-
return false;
83-
}
84-
85-
// const, but no initializer.
86-
if (!VD->getAnyInitializer()) {
87-
diagnoseMissingInitializer(S, OpPC, VD);
88-
return false;
89-
}
79+
return false;
9080
}
81+
82+
if (!D->getType().isConstQualified())
83+
diagnoseNonConstVariable(S, OpPC, D);
84+
else if (const auto *VD = dyn_cast<VarDecl>(D);
85+
VD && !VD->getAnyInitializer())
86+
diagnoseMissingInitializer(S, OpPC, VD);
87+
9188
return false;
9289
}
9390

0 commit comments

Comments
 (0)