diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-07-19 07:18:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-19 07:18:51 +0200 |
commit | ef49ed4829bc1b111e31a08d70b0ccae66427ebf (patch) | |
tree | 7773c35177b9813dc562feda358811cb63055610 /clang/lib/AST/ByteCode/Interp.cpp | |
parent | a5481e7d5af07161b5d135100cb8754ae614accf (diff) | |
download | llvm-ef49ed4829bc1b111e31a08d70b0ccae66427ebf.zip llvm-ef49ed4829bc1b111e31a08d70b0ccae66427ebf.tar.gz llvm-ef49ed4829bc1b111e31a08d70b0ccae66427ebf.tar.bz2 |
[clang][bytecode] Use bytecode interpreter in isPotentialConstantExprU… (#149462)
…nevaluated
Fake a function call to the given function and evaluate the given
expression as if it was part of that function call.
Fixes #149383
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index df5e3be..5463aec 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -142,8 +142,12 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC, return false; if (isa<ParmVarDecl>(D)) { - if (D->getType()->isReferenceType()) + if (D->getType()->isReferenceType()) { + if (S.inConstantContext() && S.getLangOpts().CPlusPlus && + !S.getLangOpts().CPlusPlus11) + diagnoseNonConstVariable(S, OpPC, D); return false; + } const SourceInfo &Loc = S.Current->getSource(OpPC); if (S.getLangOpts().CPlusPlus11) { @@ -661,6 +665,9 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr, if (Ptr.isInitialized()) return true; + if (Ptr.isExtern() && S.checkingPotentialConstantExpression()) + return false; + if (const auto *VD = Ptr.getDeclDesc()->asVarDecl(); VD && (VD->isConstexpr() || VD->hasGlobalStorage())) { |