[clang] [clang][bytecode] Reject more constexpr-unknown pointers in CheckStore (PR #194529)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 21:04:15 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Even in constant contexts.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+1-1) 
- (modified) clang/test/AST/ByteCode/openmp.cpp (+8-1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 21a75b8fb4d45..61b473942f9f7 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -894,7 +894,7 @@ bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
     return false;
   if (!CheckVolatile(S, OpPC, Ptr, AK_Assign))
     return false;
-  if (!S.inConstantContext() && isConstexprUnknown(Ptr))
+  if (isConstexprUnknown(Ptr))
     return false;
   return true;
 }
diff --git a/clang/test/AST/ByteCode/openmp.cpp b/clang/test/AST/ByteCode/openmp.cpp
index c7cccfdd1de9a..79223b2e57e7d 100644
--- a/clang/test/AST/ByteCode/openmp.cpp
+++ b/clang/test/AST/ByteCode/openmp.cpp
@@ -26,4 +26,11 @@ int test2() {
   }
 }
 
-
+void test3() {
+  char i = 0;
+  char &c = i;
+#pragma omp for collapse(2)
+  for (c = 0; c < 2; c++)
+    for (int j = 0; j < 4 + c; j++)
+      ;
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/194529


More information about the cfe-commits mailing list