https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/177565

We need to allocate those.

Fixes https://github.com/llvm/llvm-project/issues/176740

>From aeea7731e2e8146444d74dcc447dbb455f933690 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Fri, 23 Jan 2026 11:40:14 +0100
Subject: [PATCH] [clang][bytecode] Fix mulc op for IntegralAP types

We need to allocate those.

Fixes https://github.com/llvm/llvm-project/issues/176740
---
 clang/lib/AST/ByteCode/Interp.h | 11 +++++++++++
 clang/test/AST/ByteCode/c.c     |  4 ++++
 2 files changed, 15 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index b7de06f9a673e..572d131c5232a 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -409,11 +409,19 @@ inline bool Mulc(InterpState &S, CodePtr OpPC) {
 
     // real(Result) = (real(LHS) * real(RHS)) - (imag(LHS) * imag(RHS))
     T A;
+    if constexpr (needsAlloc<T>())
+      A = S.allocAP<T>(Bits);
     if (T::mul(LHSR, RHSR, Bits, &A))
       return false;
+
     T B;
+    if constexpr (needsAlloc<T>())
+      B = S.allocAP<T>(Bits);
     if (T::mul(LHSI, RHSI, Bits, &B))
       return false;
+
+    if constexpr (needsAlloc<T>())
+      Result.elem<T>(0) = S.allocAP<T>(Bits);
     if (T::sub(A, B, Bits, &Result.elem<T>(0)))
       return false;
 
@@ -422,6 +430,9 @@ inline bool Mulc(InterpState &S, CodePtr OpPC) {
       return false;
     if (T::mul(LHSI, RHSR, Bits, &B))
       return false;
+
+    if constexpr (needsAlloc<T>())
+      Result.elem<T>(1) = S.allocAP<T>(Bits);
     if (T::add(A, B, Bits, &Result.elem<T>(1)))
       return false;
     Result.initialize();
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 67a47fdcc9523..b21657fe87afa 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -417,3 +417,7 @@ void callReturnsComplex(void) {
   _Complex double c;
   c = returnsComplex(0.); // all-warning {{passing arguments to 
'returnsComplex' without a prototype is deprecated in all versions of C and is 
not supported in C23}}
 }
+
+int complexFoo[2 * (22222222222wb + 2i) == 2]; // all-warning {{'_BitInt' 
suffix for literals is a C23 extension}} \
+                                               // pedantic-warning {{imaginary 
constants are a C2y extension}} \
+                                               // all-warning {{variable 
length array folded to constant array as an extension}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to