Author: Timm Bäder Date: 2024-05-22T12:14:56+02:00 New Revision: 5cb2ea5704c733102ae93a50b10b80c1ae06112e
URL: https://github.com/llvm/llvm-project/commit/5cb2ea5704c733102ae93a50b10b80c1ae06112e DIFF: https://github.com/llvm/llvm-project/commit/5cb2ea5704c733102ae93a50b10b80c1ae06112e.diff LOG: [clang][Interp][NFC] Remove VarDecl requirement in diagnoseUnknownDecl() We can call diagnoseNonConstVariable() for all ValueDecls just fine. Added: Modified: clang/lib/AST/Interp/Interp.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp index 3e4da487e43c3..1ed2ff30bdd05 100644 --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -76,18 +76,15 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC, } else { S.FFDiag(E); } - } else if (const auto *VD = dyn_cast<VarDecl>(D)) { - if (!VD->getType().isConstQualified()) { - diagnoseNonConstVariable(S, OpPC, VD); - return false; - } - - // const, but no initializer. - if (!VD->getAnyInitializer()) { - diagnoseMissingInitializer(S, OpPC, VD); - return false; - } + return false; } + + if (!D->getType().isConstQualified()) + diagnoseNonConstVariable(S, OpPC, D); + else if (const auto *VD = dyn_cast<VarDecl>(D); + VD && !VD->getAnyInitializer()) + diagnoseMissingInitializer(S, OpPC, VD); + return false; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits