diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-09-19 14:24:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-19 14:24:48 +0200 |
commit | 68c9ddb93022f46f49d8b1a6063065d3a15aba0f (patch) | |
tree | 0f93b2e9ebe28e69882cde406560283e6f9619b1 /clang/lib/AST/ByteCode/Interp.cpp | |
parent | b7e4edca3d56ec87f719c202f5397b245595f7cc (diff) | |
download | llvm-68c9ddb93022f46f49d8b1a6063065d3a15aba0f.zip llvm-68c9ddb93022f46f49d8b1a6063065d3a15aba0f.tar.gz llvm-68c9ddb93022f46f49d8b1a6063065d3a15aba0f.tar.bz2 |
[clang][bytecode] Typecheck called function pointers more thorougly (#159757)
Fix two older FIXME items from the `functions.cpp` test.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index d5e75a0..0f322f6 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1750,9 +1750,8 @@ bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize, const Pointer &Ptr = S.Stk.pop<Pointer>(); if (Ptr.isZero()) { - const auto *E = cast<CallExpr>(S.Current->getExpr(OpPC)); - S.FFDiag(E, diag::note_constexpr_null_callee) - << const_cast<Expr *>(E->getCallee()) << E->getSourceRange(); + S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_null_callee) + << const_cast<Expr *>(CE->getCallee()) << CE->getSourceRange(); return false; } @@ -1778,6 +1777,14 @@ bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize, return false; } + // Can happen when casting function pointers around. + QualType CalleeType = CE->getCallee()->getType(); + if (CalleeType->isPointerType() && + !S.getASTContext().hasSameFunctionTypeIgnoringExceptionSpec( + F->getDecl()->getType(), CalleeType->getPointeeType())) { + return false; + } + assert(ArgSize >= F->getWrittenArgSize()); uint32_t VarArgSize = ArgSize - F->getWrittenArgSize(); |