https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/189033

Negation can also fail for fixed-point values.

>From ca8ccced65f0899e2c1c120954b757f41b665f58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Fri, 27 Mar 2026 16:58:15 +0100
Subject: [PATCH] [clang][bytecode] Fix an assertion failure with fixed-point
 types

Negation can also fail for fixed-point values.
---
 clang/lib/AST/ByteCode/Interp.h             | 2 +-
 clang/test/Frontend/fixed_point_sub_const.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 90dc88c1dbde7..3578ef9da820b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -720,7 +720,7 @@ bool Neg(InterpState &S, CodePtr OpPC) {
       return true;
     }
 
-    assert(isIntegerType(Name) &&
+    assert((isIntegerType(Name) || Name == PT_FixedPoint) &&
            "don't expect other types to fail at constexpr negation");
     S.Stk.push<T>(Result);
 
diff --git a/clang/test/Frontend/fixed_point_sub_const.c 
b/clang/test/Frontend/fixed_point_sub_const.c
index c98cfd185205c..ab49799673eae 100644
--- a/clang/test/Frontend/fixed_point_sub_const.c
+++ b/clang/test/Frontend/fixed_point_sub_const.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
+
 // Subtraction between different fixed point types
 short _Accum sa_const = 1.0hk - 2.0hk;
 // CHECK-DAG: @sa_const  = {{.*}}global i16 -128, align 2

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

Reply via email to