llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/199657.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.h (+5) 
- (modified) clang/test/AST/ByteCode/const-eval.c (+4) 


``````````diff
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}}

``````````

</details>


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

Reply via email to