https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/179676
If they are invalid. This is what the current interpreter does. >From 2b9d6b2f3b05f251dff2372f8c86c01e993993bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Wed, 4 Feb 2026 15:39:50 +0100 Subject: [PATCH] [clang][bytecode] Return Invalid() from atomic_is_lock_free calls If they are invalid. This is what the current interpreter does. --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 2 +- clang/test/AST/ByteCode/builtins.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index a6b016c14184a..bbceb28e94a6d 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1125,7 +1125,7 @@ static bool interp__builtin_atomic_lock_free(InterpState &S, CodePtr OpPC, if (BuiltinOp == Builtin::BI__atomic_always_lock_free) return returnBool(false); - return false; + return Invalid(S, OpPC); } /// bool __c11_atomic_is_lock_free(size_t) diff --git a/clang/test/AST/ByteCode/builtins.c b/clang/test/AST/ByteCode/builtins.c index 684db52296fc2..5630a36e1c05b 100644 --- a/clang/test/AST/ByteCode/builtins.c +++ b/clang/test/AST/ByteCode/builtins.c @@ -1,8 +1,5 @@ -// RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -verify -// RUN: %clang_cc1 %s -verify=ref - -// expected-no-diagnostics -// ref-no-diagnostics +// RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -verify=expected,both +// RUN: %clang_cc1 %s -verify=ref,both extern __SIZE_TYPE__ strlen(const char *); @@ -19,3 +16,6 @@ int structStrlen(void) { void f() { __builtin_memcpy(f, f, 1); } void f2() { __builtin_memchr(f2, 0, 1); } + + +_Static_assert(__atomic_is_lock_free(4, (void*)2), ""); // both-error {{not an integral constant expression}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
