[cfe-commits] r64708 - in /cfe/trunk: Driver/clang.cpp test/Sema/unused-expr.c

Chris Lattner sabre at nondot.org
Mon Feb 16 16:35:10 PST 2009


Author: lattner
Date: Mon Feb 16 18:35:09 2009
New Revision: 64708

URL: http://llvm.org/viewvc/llvm-project?rev=64708&view=rev
Log:
add support for -fno-math-errno, and validate that it affects sema properly.

Modified:
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/test/Sema/unused-expr.c

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=64708&r1=64707&r2=64708&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Feb 16 18:35:09 2009
@@ -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.

Modified: cfe/trunk/test/Sema/unused-expr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unused-expr.c?rev=64708&r1=64707&r2=64708&view=diff

==============================================================================
--- cfe/trunk/test/Sema/unused-expr.c (original)
+++ cfe/trunk/test/Sema/unused-expr.c Mon Feb 16 18:35:09 2009
@@ -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();





More information about the cfe-commits mailing list