[flang-commits] [clang] [flang] [llvm] [flang][flang-rt] Add -ffpe-trap= to set the initial FP exception halting mode (PR #208828)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Wed Jul 22 07:33:04 PDT 2026


================
@@ -0,0 +1,31 @@
+! Test that -ffpe-trap= generates a call to _FortranAEnableFPETraps in main().
+
+! RUN: %flang_fc1 -emit-fir -ffpe-trap=invalid %s -o - | FileCheck --check-prefix=CHECK-INVALID %s
+! RUN: %flang_fc1 -emit-fir -ffpe-trap=invalid,zero,overflow %s -o - | FileCheck --check-prefix=CHECK-MULTI %s
+! RUN: %flang_fc1 -emit-fir -ffpe-trap=invalid,underflow,inexact,denormal %s -o - | FileCheck --check-prefix=CHECK-EXT %s
+! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+! RUN: %flang_fc1 -emit-fir -ffpe-trap=none %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+! RUN: %flang_fc1 -emit-fir -ffpe-trap=invalid,none %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+
+program test
+  continue
+end
+
+! CHECK-INVALID: %[[TRAPS:.*]] = arith.constant 1 : i32
+! CHECK-INVALID: fir.call @_FortranAProgramStart(
+! CHECK-INVALID: fir.call @_FortranAEnableFPETraps(%[[TRAPS]])
+! CHECK-INVALID: fir.call @_QQmain
+
+! invalid=1, zero=4, overflow=8 => 13
+! CHECK-MULTI: %[[TRAPS:.*]] = arith.constant 13 : i32
----------------
tarunprabhu wrote:

nit: Is there precedence for reusing the same name like this? If there is, it's fine. I just find it easier if distinct names are used. Perhaps it could be named to match the label, so `MULTI` in this case?

https://github.com/llvm/llvm-project/pull/208828


More information about the flang-commits mailing list