[cfe-commits] r97284 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Lexer/constants.c

John McCall rjmccall at apple.com
Fri Feb 26 15:35:57 PST 2010


Author: rjmccall
Date: Fri Feb 26 17:35:57 2010
New Revision: 97284

URL: http://llvm.org/viewvc/llvm-project?rev=97284&view=rev
Log:
At sabre's request, drop the FP bounds diagnostics down to warnings and file
them under -Wbad-literal.  They're still on by default.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Lexer/constants.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=97284&r1=97283&r2=97284&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Feb 26 17:35:57 2010
@@ -24,6 +24,7 @@
 def : DiagGroup<"aggregate-return">;
 def : DiagGroup<"attributes">;
 def : DiagGroup<"bad-function-cast">;
+def BadLiteral : DiagGroup<"bad-literal">; // not in gcc
 def : DiagGroup<"c++-compat">;
 def : DiagGroup<"cast-align">;
 def : DiagGroup<"cast-qual">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=97284&r1=97283&r2=97284&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 26 17:35:57 2010
@@ -29,10 +29,12 @@
 // Semantic analysis of constant literals.
 def ext_predef_outside_function : Warning<
   "predefined identifier is only valid inside function">;
-def err_float_overflow : Error<
-  "magnitude of floating-point constant too large for type %0; maximum is %1">;
-def err_float_underflow : Error<
-  "magnitude of floating-point constant too small for type %0; minimum is %1">;
+def warn_float_overflow : Warning<
+  "magnitude of floating-point constant too large for type %0; maximum is %1">,
+   InGroup<BadLiteral>;
+def warn_float_underflow : Warning<
+  "magnitude of floating-point constant too small for type %0; minimum is %1">,
+  InGroup<BadLiteral>;
 
 // C99 Designated Initializers
 def err_array_designator_negative : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=97284&r1=97283&r2=97284&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Feb 26 17:35:57 2010
@@ -1736,10 +1736,10 @@
       unsigned diagnostic;
       llvm::SmallVector<char, 20> buffer;
       if (result & APFloat::opOverflow) {
-        diagnostic = diag::err_float_overflow;
+        diagnostic = diag::warn_float_overflow;
         APFloat::getLargest(Format).toString(buffer);
       } else {
-        diagnostic = diag::err_float_underflow;
+        diagnostic = diag::warn_float_underflow;
         APFloat::getSmallest(Format).toString(buffer);
       }
 

Modified: cfe/trunk/test/Lexer/constants.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/constants.c?rev=97284&r1=97283&r2=97284&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/constants.c (original)
+++ cfe/trunk/test/Lexer/constants.c Fri Feb 26 17:35:57 2010
@@ -38,20 +38,20 @@
 float t0[] = {
   1.9e20f,
   1.9e-20f,
-  1.9e50f,   // expected-error {{too large}}
-  1.9e-50f,  // expected-error {{too small}}
+  1.9e50f,   // expected-warning {{too large}}
+  1.9e-50f,  // expected-warning {{too small}}
   -1.9e20f,
   -1.9e-20f,
-  -1.9e50f,  // expected-error {{too large}}
-  -1.9e-50f  // expected-error {{too small}}
+  -1.9e50f,  // expected-warning {{too large}}
+  -1.9e-50f  // expected-warning {{too small}}
 };
 double t1[] = {
   1.9e50,
   1.9e-50,
-  1.9e500,   // expected-error {{too large}}
-  1.9e-500,  // expected-error {{too small}}
+  1.9e500,   // expected-warning {{too large}}
+  1.9e-500,  // expected-warning {{too small}}
   -1.9e50,
   -1.9e-50,
-  -1.9e500,  // expected-error {{too large}}
-  -1.9e-500  // expected-error {{too small}}
+  -1.9e500,  // expected-warning {{too large}}
+  -1.9e-500  // expected-warning {{too small}}
 };





More information about the cfe-commits mailing list