[clang] [clang][bytecode] Check CarrayOutPtr in subcl more thorougly (PR #203172)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 22:06:05 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/203172
Use the local `isReadable` check.
>From a008a0c2c5823625ad9f54dc1b52ca265924f1b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 11 Jun 2026 07:05:01 +0200
Subject: [PATCH] [clang][bytecode] Check CarrayOutPtr in subcl more thorougly
Use the local `isReadable` check.
---
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 2 +-
clang/test/AST/ByteCode/builtins.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
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}}
+}
More information about the cfe-commits
mailing list