[clang] [clang][bytecode] Check CarrayOutPtr in subcl more thorougly (PR #203172)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 22:06:47 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
Use the local `isReadable` check.
---
Full diff: https://github.com/llvm/llvm-project/pull/203172.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+1-1)
- (modified) clang/test/AST/ByteCode/builtins.c (+4)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 08fc8252d0708..4326142aba81f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -984,7 +984,7 @@ static bool interp__builtin_carryop(InterpState &S, CodePtr OpPC,
if (!popToAPSInt(S.Stk, LHST, LHS))
return false;
- if (CarryOutPtr.isDummy() || !CarryOutPtr.isBlockPointer())
+ if (!isReadable(CarryOutPtr))
return false;
APSInt CarryOut;
diff --git a/clang/test/AST/ByteCode/builtins.c b/clang/test/AST/ByteCode/builtins.c
index dc19d197d0a2e..8af1c5cc90616 100644
--- a/clang/test/AST/ByteCode/builtins.c
+++ b/clang/test/AST/ByteCode/builtins.c
@@ -37,3 +37,7 @@ const int compared = strcmp(_str, (const char *)_str2); // both-error {{initiali
int ptrint = __builtin_bswap64("") == 0x1234 ? 1 : 0; // both-error {{incompatible pointer to integer conversion}} \
// both-error {{initializer element is not a compile-time constant}}
+
+void subclNonReadable() {
+ if(__builtin_subcl(0, 0, 0, &(*({ struct {} x; &x; }))) != 0) {} // both-error {{incompatible pointer types}}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/203172
More information about the cfe-commits
mailing list