[clang] [clang] Expose -f(no-)math-errno as a clang-cl option (PR #195455)

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Sat May 2 07:46:58 PDT 2026


https://github.com/nico created https://github.com/llvm/llvm-project/pull/195455

Vaguely related: https://developercommunity.visualstudio.com/t/Add-a-flag-similar-to--fno-math-errno-th/10710444

>From e025f1ee3df9e0cc59c72da010c33573eda21dae Mon Sep 17 00:00:00 2001
From: Nico Weber <thakis at chromium.org>
Date: Sat, 2 May 2026 10:45:59 -0400
Subject: [PATCH] [clang] Expose -f(no-)math-errno as a clang-cl option

---
 clang/include/clang/Options/Options.td | 2 +-
 clang/test/Driver/cl-options.c         | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td
index c16c41ad4057d..09e969cbbc2c0 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -2417,7 +2417,7 @@ defm fast_math : BoolFOption<"fast-math",
   NegFlag<SetFalse, [], [ClangOption, CC1Option, FC1Option, FlangOption]>>;
 defm math_errno : BoolFOption<"math-errno",
   LangOpts<"MathErrno">, DefaultFalse,
-  PosFlag<SetTrue, [], [ClangOption, CC1Option],
+  PosFlag<SetTrue, [], [ClangOption, CLOption, CC1Option],
           "Require math functions to indicate errors by setting errno">,
   NegFlag<SetFalse>>,
   ShouldParseIf<!strconcat("!", open_cl.KeyPath)>;
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 37f8081e6be4f..c0f57ae768252 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -755,6 +755,8 @@
 // RUN:     -fcs-profile-generate=dir \
 // RUN:     -fpseudo-probe-for-profiling \
 // RUN:     -ftime-trace \
+// RUN:     -fmath-errno \
+// RUN:     -fno-math-errno \
 // RUN:     -fmodules \
 // RUN:     -fno-modules \
 // RUN:     -fimplicit-module-maps \



More information about the cfe-commits mailing list