https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/199657
>From 537eb911f5dd40b750d3a38dde9f0d67e732fb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Tue, 26 May 2026 13:27:37 +0200 Subject: [PATCH] [clang][bytecode] Check Mulc op for numbers --- clang/lib/AST/ByteCode/Interp.h | 5 +++++ clang/test/AST/ByteCode/const-eval.c | 4 ++++ 2 files changed, 9 insertions(+) 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
