summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/Driver/clang.cpp2
-rw-r--r--clang/test/Sema/unused-expr.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index a2578a4f797..deea08c3353 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -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.
diff --git a/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c
index 4cc829be046..a44d1c8fed4 100644
--- a/clang/test/Sema/unused-expr.c
+++ b/clang/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 @@ 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();
OpenPOWER on IntegriCloud