[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,65 @@
+! Test that -ffpe-trap= is forwarded from the Flang driver to the frontend.
+
+! RUN: %flang -ffpe-trap=invalid,zero,overflow -fsyntax-only -### %s 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-FORWARD %s
+! CHECK-FORWARD: -fc1
+! CHECK-FORWARD-SAME: -ffpe-trap=invalid,zero,overflow
+
+! Test all supported exception types
+! RUN: %flang -ffpe-trap=invalid,zero,overflow,underflow,inexact,denormal -fsyntax-only -### %s 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-ALL %s
+! CHECK-ALL: -fc1
+! CHECK-ALL-SAME: -ffpe-trap=invalid,zero,overflow,underflow,inexact,denormal
+
+! Test a single exception type
+! RUN: %flang -ffpe-trap=invalid -fsyntax-only -### %s 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-SINGLE %s
+! CHECK-SINGLE: -fc1
+! CHECK-SINGLE-SAME: -ffpe-trap=invalid
+
+! Only the last -ffpe-trap= is forwarded to the frontend.
+! RUN: %flang -ffpe-trap=invalid -ffpe-trap=overflow -fsyntax-only -### %s 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-LAST %s
+! CHECK-LAST: -fc1
+! CHECK-LAST-SAME: -ffpe-trap=overflow
+! CHECK-LAST-NOT: -ffpe-trap=invalid
+
+! "none" and an empty list are accepted and disable halting.
+! RUN: %flang_fc1 -ffpe-trap=none -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-OK --allow-empty %s
+! RUN: %flang_fc1 -ffpe-trap= -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-OK --allow-empty %s
+! RUN: %flang_fc1 -ffpe-trap=invalid,none -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-OK --allow-empty %s
+! CHECK-OK-NOT: error:
----------------
tarunprabhu wrote:
This is not necessary. If an error were to occur, a non-zero error code would be returned and this test would fail.
https://github.com/llvm/llvm-project/pull/208828
More information about the flang-commits
mailing list