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 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