]> granicus.if.org Git - clang/commitdiff
add support for -fno-math-errno, and validate that it affects sema properly.
authorChris Lattner <sabre@nondot.org>
Tue, 17 Feb 2009 00:35:09 +0000 (00:35 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Feb 2009 00:35:09 +0000 (00:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64708 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp
test/Sema/unused-expr.c

index a2578a4f7978ff704f369cd5862d8fe0e0a07080..deea08c3353ab6cb41666b4b1a7efb34135efc89 100644 (file)
@@ -219,7 +219,7 @@ Freestanding("ffreestanding",
 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.
index 4cc829be046d790ab160ea036142ec7c5fd66a80..a44d1c8fed437a24279f4883c233bc167e4d5f57 100644 (file)
@@ -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 @@ void bar(volatile int *VP, int *P, int A,
 
   __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();