Author: Timm Baeder Date: 2026-05-29T08:34:42Z New Revision: 2e10a9f2e95a17d4d009e9546a6cb5d442049233
URL: https://github.com/llvm/llvm-project/commit/2e10a9f2e95a17d4d009e9546a6cb5d442049233 DIFF: https://github.com/llvm/llvm-project/commit/2e10a9f2e95a17d4d009e9546a6cb5d442049233.diff LOG: [clang][bytecode] Check Mulc op for numbers (#199657) Added: Modified: clang/lib/AST/ByteCode/Interp.h clang/test/AST/ByteCode/const-eval.c Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 4d2055cdb8385..a255a1fdf6f16 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -520,6 +520,11 @@ inline bool Mulc(InterpState &S, CodePtr OpPC) { const T &RHSI = RHS.elem<T>(1); unsigned Bits = LHSR.bitWidth(); + // We only handle actual numbers here. + if (!LHSR.isNumber() || !LHSI.isNumber() || !RHSR.isNumber() || + !RHSI.isNumber()) + return false; + // real(Result) = (real(LHS) * real(RHS)) - (imag(LHS) * imag(RHS)) T A; if constexpr (needsAlloc<T>()) diff --git a/clang/test/AST/ByteCode/const-eval.c b/clang/test/AST/ByteCode/const-eval.c index 9805fc042c470..1d30c87374c05 100644 --- a/clang/test/AST/ByteCode/const-eval.c +++ b/clang/test/AST/ByteCode/const-eval.c @@ -185,3 +185,7 @@ union ToUnion_U { struct ToUnion_X x; double y; int z : 3; }; _Static_assert(((union ToUnion_U)(struct ToUnion_X){67}).x.a == 67, ""); _Static_assert(((union ToUnion_U)1.0).y == 1.0, ""); _Static_assert(((union ToUnion_U)9).z == 1, ""); + +struct S s; // both-error {{tentative definition has type 'struct S' that is never completed}} \ + // both-note {{forward declaration of 'struct S'}} +int foo[2 * ((long)&s + 42i) == 2]; // both-error {{variable length array declaration not allowed at file scope}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
