Author: Timm Baeder Date: 2025-03-05T16:21:03+01:00 New Revision: bdbc434498016ee22c06983c8b2725c169326b66
URL: https://github.com/llvm/llvm-project/commit/bdbc434498016ee22c06983c8b2725c169326b66 DIFF: https://github.com/llvm/llvm-project/commit/bdbc434498016ee22c06983c8b2725c169326b66.diff LOG: [clang][bytecode] Ignore function calls with depth > 0... (#129887) ... when checking for a potential constant expression. This is also what the current interpreter does. Added: Modified: clang/lib/AST/ByteCode/Interp.cpp clang/test/AST/ByteCode/functions.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index a2090f3e85e08..1107c0c32792f 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -714,6 +714,9 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) { return false; } + if (S.checkingPotentialConstantExpression() && S.Current->getDepth() != 0) + return false; + if (F->isConstexpr() && F->hasBody() && (F->getDecl()->isConstexpr() || F->getDecl()->hasAttr<MSConstexprAttr>())) return true; diff --git a/clang/test/AST/ByteCode/functions.cpp b/clang/test/AST/ByteCode/functions.cpp index a7c8836eac6b8..a767d104b3c8a 100644 --- a/clang/test/AST/ByteCode/functions.cpp +++ b/clang/test/AST/ByteCode/functions.cpp @@ -681,3 +681,16 @@ namespace StableAddress { static_assert(sum<str{"$hello $world."}>() == 1234, ""); } #endif + +namespace NoDiags { + void huh(); + template <unsigned> + constexpr void hd_fun() { + huh(); + } + + constexpr bool foo() { + hd_fun<1>(); + return true; + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits