add support for -fno-math-errno, and validate that it affects sema properly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64708 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index a2578a4..deea08c 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -219,7 +219,7 @@
 static llvm::cl::opt<bool>
 MathErrno("fmath-errno", 
           llvm::cl::desc("Require math functions to respect errno"),
-          llvm::cl::init(true));
+          llvm::cl::init(true), llvm::cl::AllowInverse);
 
 //===----------------------------------------------------------------------===//
 // Analyzer Options.
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c
index 4cc829b..a44d1c8 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -1,7 +1,9 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify -fno-math-errno %s
 
 int foo(int X, int Y);
 
+double sqrt(double X);  // implicitly const because of -fno-math-errno!
+
 void bar(volatile int *VP, int *P, int A,
          _Complex double C, volatile _Complex double VC) {
   
@@ -21,6 +23,9 @@
 
   __real__ C;          // expected-warning {{expression result unused}}
   __real__ VC;
+  
+  // We know this can't change errno because of -fno-math-errno.
+  sqrt(A);  // expected-warning {{expression result unused}}
 }
 
 extern void t1();