[PATCH] D116337: [clang] set __NO_MATH_ERRNO__ if -fno-math-errno

Alex Xu (Hello71) via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 5 14:02:01 PST 2022


alxu updated this revision to Diff 397708.
alxu added a comment.

In D116337#3217955 <https://reviews.llvm.org/D116337#3217955>, @aaron.ballman wrote:

> Thanks for this! I'm adding some more reviewers to the list to help get this reviewed.
>
> The patch doesn't seem to apply cleanly, so precommit CI isn't running on it. Can you rectify that?

GNU patch applies the patch with offset 20 and no fuzz on llvm-project main. However, I have included a rebase from llvm 13 to llvm main along with the tests in the new patch.

> Also, the change needs test coverage of some kind.

Added.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116337/new/

https://reviews.llvm.org/D116337

Files:
  ../clang/lib/Frontend/InitPreprocessor.cpp 
  ../clang/test/Preprocessor/predefined-macros.c


Index: ../clang/test/Preprocessor/predefined-macros.c     
===================================================================
--- ../clang/test/Preprocessor/predefined-macros.c     
+++ ../clang/test/Preprocessor/predefined-macros.c     
@@ -59,8 +59,17 @@
 // RUN: %clang_cc1 %s -E -dM -ffast-math -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FAST-MATH
 // CHECK-FAST-MATH: #define __FAST_MATH__ 1
+// CHECK-FAST-MATH: #define __NO_MATH_ERRNO__ 1
 // CHECK-FAST-MATH: #define __FINITE_MATH_ONLY__ 1
 //
+// RUN: %clang_cc1 %s -E -dM -fmath-errno -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-MATH-ERRNO
+// CHECK-MATH-ERRNO-NOT: __NO_MATH_ERRNO__
+//
+// RUN: %clang %s -E -dM -fno-math-errno -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-NO-MATH-ERRNO
+// CHECK-NO-MATH-ERRNO: #define __NO_MATH_ERRNO__ 1
+//
 // RUN: %clang_cc1 %s -E -dM -ffinite-math-only -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FINITE-MATH-ONLY
 // CHECK-FINITE-MATH-ONLY: #define __FINITE_MATH_ONLY__ 1
Index: ../clang/lib/Frontend/InitPreprocessor.cpp 
===================================================================
--- ../clang/lib/Frontend/InitPreprocessor.cpp 
+++ ../clang/lib/Frontend/InitPreprocessor.cpp 
@@ -1039,6 +1039,9 @@

   Builder.defineMacro("__USER_LABEL_PREFIX__", TI.getUserLabelPrefix());

+  if (LangOpts.MathErrno)
+    Builder.defineMacro("__NO_MATH_ERRNO__");
+
   if (LangOpts.FastMath || LangOpts.FiniteMathOnly)
     Builder.defineMacro("__FINITE_MATH_ONLY__", "1");
   else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116337.397708.patch
Type: text/x-patch
Size: 1593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220105/7c21300f/attachment.bin>


More information about the cfe-commits mailing list