From: Chris Lattner Date: Tue, 17 Feb 2009 00:35:09 +0000 (+0000) Subject: add support for -fno-math-errno, and validate that it affects sema properly. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5bef8ddabfe157aa6f1f9010d3d144215b3e731a;p=clang 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 a2578a4f79..deea08c335 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -219,7 +219,7 @@ Freestanding("ffreestanding", static llvm::cl::opt 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 4cc829be04..a44d1c8fed 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 @@ 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();