Author: Timm Baeder
Date: 2026-03-27T17:55:29+01:00
New Revision: 76036032d6eb4b4a0dec034508bf5118168adf19

URL: 
https://github.com/llvm/llvm-project/commit/76036032d6eb4b4a0dec034508bf5118168adf19
DIFF: 
https://github.com/llvm/llvm-project/commit/76036032d6eb4b4a0dec034508bf5118168adf19.diff

LOG: [clang][bytecode] Fix an assertion failure with fixed-point types (#189033)

Negation can also fail for fixed-point values.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Interp.h
    clang/test/Frontend/fixed_point_sub_const.c

Removed: 
    


################################################################################
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 
diff erent 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