llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We need to allocate those. Fixes https://github.com/llvm/llvm-project/issues/176740 --- Full diff: https://github.com/llvm/llvm-project/pull/177565.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.h (+11) - (modified) clang/test/AST/ByteCode/c.c (+4) ``````````diff 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}} `````````` </details> https://github.com/llvm/llvm-project/pull/177565 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
