]> granicus.if.org Git - clang/commitdiff
Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 19 Sep 2010 21:21:44 +0000 (21:21 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sun, 19 Sep 2010 21:21:44 +0000 (21:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114316 91177308-0d34-0410-b5e6-96231b3b80d8

18 files changed:
include/clang/Basic/DiagnosticSemaKinds.td
test/Analysis/dead-stores.c
test/Analysis/misc-ps.m
test/Misc/caret-diags-macros.c
test/Parser/expressions.m
test/Parser/objc-messaging-1.m
test/Parser/objc-try-catch-1.m
test/Preprocessor/pragma_microsoft.c
test/Sema/enum.c
test/Sema/ext_vector_components.c
test/Sema/i-c-e.c
test/Sema/statements.c
test/Sema/unused-expr.c
test/SemaCXX/cast-conversion.cpp
test/SemaCXX/decl-expr-ambiguity.cpp
test/SemaCXX/overloaded-operator.cpp
test/SemaCXX/warn-unused-variables.cpp
test/SemaObjC/invalid-code.m

index 9508c913ec341e0998e05134fecf901ad8e0dacf..68d504fc1c0708bf126a708a14fee0f542f4b436 100644 (file)
@@ -2770,16 +2770,16 @@ def ext_typecheck_expression_not_constant_but_accepted : Extension<
   "expression is not a constant, but is accepted as one by GNU extensions">, 
   InGroup<GNU>;
 def warn_unused_expr : Warning<"expression result unused">,
-  InGroup<UnusedValue>;
+  InGroup<UnusedValue>, DefaultIgnore;
 def warn_unused_voidptr : Warning<
   "expression result unused; should this cast be to 'void'?">,
-  InGroup<UnusedValue>;
+  InGroup<UnusedValue>, DefaultIgnore;
 def warn_unused_property_expr : Warning<
  "property access result unused - getters should not be used for side effects">,
-  InGroup<UnusedValue>;
+  InGroup<UnusedValue>, DefaultIgnore;
 def warn_unused_call : Warning<
   "ignoring return value of function declared with %0 attribute">,
-  InGroup<UnusedValue>;
+  InGroup<UnusedValue>, DefaultIgnore;
 
 def err_incomplete_type_used_in_type_trait_expr : Error<
   "incomplete type %0 used in type trait expression">;
index c150fa088d812693fa9d49b8a012cbb5d638feb2..ad7890b6b18428f1048bca0fae2ed9f714371172 100644 (file)
@@ -300,11 +300,11 @@ void f22() {
   case 7:
     (void)(0 && x);
     (void)y7;
-    (void)(0 || (y8, ({ return; }), 1));  // expected-warning {{expression result unused}}
+    (void)(0 || (y8, ({ return; }), 1));
     (void)x;
     break;
   case 8:
-    (void)(1 && (y9, ({ return; }), 1));  // expected-warning {{expression result unused}}
+    (void)(1 && (y9, ({ return; }), 1));
     (void)x;
     break;
   case 9:
index bb70c90e6a62276f8d36b33ac62ef7ec2446d441..190c605b5c70327c192f58d33e8c489f1c607460 100644 (file)
@@ -466,7 +466,7 @@ unsigned char test_array_index_bitwidth(const unsigned char *p) {
 // It should not crash.
 void test_block_cast() {
   id test_block_cast_aux();
-  (void (^)(void *))test_block_cast_aux(); // expected-warning{{expression result unused}}
+  (void (^)(void *))test_block_cast_aux();
 }
 
 int OSAtomicCompareAndSwap32Barrier();
@@ -673,7 +673,7 @@ CGFloat rdar7242006(CGFloat x) {
 //  when not explicitly used in an "lvalue" context (as far as the analyzer is
 //  concerned). This previously triggered a crash due to an invalid assertion.
 void pr_4988(void) {
-  pr_4988; // expected-warning{{expression result unused}}
+  pr_4988;
 }
 
 // <rdar://problem/7152418> - A 'signed char' is used as a flag, which is
index e138f59d608c9a1af917e353442c358c697f1bd2..90902dba82a036c5e4453f94d02a7aa1dc812769 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s > %t 2>&1
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value %s > %t 2>&1
 
 #define M1(x) x
 
index 1f1005a792a777cb5dd24f58bdd9f77194c2e05b..95042327d1b2ca36e25f19ce76041522e83ae1bf 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wunused-value -fsyntax-only -verify %s
 
 void test1() {
   @"s";            // expected-warning {{expression result unused}}
index 82450df9f2c36cf78714b92177a316bbbc0eed05..0708989728a38b539049497f35884b4103532d96 100644 (file)
@@ -6,21 +6,14 @@ int main ()
         id a, b, c;
        [a ii]; // expected-warning{{not found}}
        [a if: 1 :2]; // expected-warning{{not found}}
-       [a inout: 1 :2 another:(2,3,4)]; // expected-warning{{not found}} \
-           // expected-warning 2{{expression result unused}}
-       [a inout: 1 :2 another:(2,3,4), 6,6,8]; // expected-warning{{not found}} \
-           // expected-warning 2{{expression result unused}}
-       [a inout: 1 :2 another:(2,3,4), (6,4,5),6,8]; // expected-warning{{not found}} \
-           // expected-warning 4{{expression result unused}}
-       [a inout: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \
-           // expected-warning 2{{expression result unused}}
-       [a long: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \
-           // expected-warning 2{{expression result unused}}
-       [a : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \
-           // expected-warning 2{{expression result unused}}
+       [a inout: 1 :2 another:(2,3,4)]; // expected-warning{{not found}}
+       [a inout: 1 :2 another:(2,3,4), 6,6,8]; // expected-warning{{not found}}
+       [a inout: 1 :2 another:(2,3,4), (6,4,5),6,8]; // expected-warning{{not found}}
+       [a inout: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}}
+       [a long: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}}
+       [a : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}}
 
        // Comma expression as receiver (rdar://6222856)
-       [a, b, c foo]; // expected-warning{{not found}} \
-           // expected-warning 2{{expression result unused}}
+       [a, b, c foo]; // expected-warning{{not found}}
 
 }
index 719369124e5cf4d380a40f3c3d40c63e53c1f954..00c86e7a43b4c655f6b7fc1cdfd9fef5e97a9757 100644 (file)
@@ -27,15 +27,13 @@ void * foo()
       return proc();
     }
     @catch (Frob* ex) {
-      @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}} \
-                                 // expected-warning {{expression result unused}}
+      @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}
     }
     @catch (float x) {  // expected-error {{@catch parameter is not a pointer to an interface type}}
       
     }
     @catch(...) {
-      @throw (4,3,proc()); // expected-warning {{expression result unused}} \
-                                                  // expected-warning {{expression result unused}}
+      @throw (4,3,proc());
     }
   }
 
@@ -48,7 +46,7 @@ void * foo()
 void bar()
 {
   @try {}// expected-error {{@try statement without a @catch and @finally clause}}
-  @"s"; //  expected-warning {{result unused}}
+  @"s";
 }
 
 void baz()
index b68d6e363eb8f263703806253e2849d75f0209be..0300e43764cf63987553a060a83c847e6cb419ff 100644 (file)
@@ -36,5 +36,5 @@ void f()
 
   // If we ever actually *support* __pragma(warning(disable: x)),
   // this warning should go away.
-  MACRO_WITH__PRAGMA // expected-warning {{expression result unused}}
+  MACRO_WITH__PRAGMA
 }
index 64aa31bc4b6f307e49357f2d4ba461b20ddba319..5782cb8daf9fe2857e9921cc0bd04ec029722c60 100644 (file)
@@ -44,10 +44,10 @@ void test4() {
     ;
   (_Bool)ve2;  // expected-error {{arithmetic or pointer type is required}}
 
-  for (; ;ve2) // expected-warning {{expression result unused}}
+  for (; ;ve2)
     ;
   (void)ve2;
-  ve2;         // expected-warning {{expression result unused}}
+  ve2;
 }
 
 // PR2416
index 7d3d52aa954683a3d8f71067f581e3362545976d..1b663528fb878eec0c6a95d4ece55ef6964cc828 100644 (file)
@@ -16,7 +16,7 @@ static void test() {
 
     vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
     vec2.xyzw; // expected-error {{vector component access exceeds type 'float2'}}
-    vec4.xyzw; // expected-warning {{expression result unused}}
+    vec4.xyzw;
     vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
     vec4.s01z; // expected-error {{illegal vector component name 'z'}}
     vec2 = vec4.s01; // legal, shorten
index eb77bbe3b99023b32052bd861aa454ccc9e9ffa0..b4a6a69ccef2df1115f47f3a5bfbce04b921cb96 100644 (file)
@@ -50,11 +50,9 @@ char y[__builtin_constant_p(expr) ? -1 : 1];
 char z[__builtin_constant_p(4) ? 1 : -1];
 
 // Comma tests
-int comma1[0?1,2:3];  // expected-warning {{expression result unused}}
-int comma2[1||(1,2)]; // expected-warning {{expression result unused}} \
-                      // expected-warning {{use of logical || with constant operand}}
-int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}} \
-                                       // expected-warning {{expression result unused}}
+int comma1[0?1,2:3];
+int comma2[1||(1,2)]; // expected-warning {{use of logical || with constant operand}}
+int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}}
 
 // Pointer + __builtin_constant_p
 char pbcp[__builtin_constant_p(4) ? (intptr_t)&expr : 0]; // expected-error {{variable length array declaration not allowed at file scope}}
index 61eafe6ff038acb6b13e46cdb004a41805cbe48a..428ad3128c8ac48958e163030d950196b66d99d0 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -Wunused-value -verify
 
 typedef unsigned __uint32_t;
 
index 15608ec8a4bebe7e54babe2ddd27dadae417aa82..ac209eb3ab4dd59dc2120c5bcebd13922edcbcc3 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code -Wunused-value
 
 int foo(int X, int Y);
 
index d68e789c370f72051ebd9ed124d44e420a8bc86b..9ca8d15b859cc8a47c28adb61117479a7dcd09c8 100644 (file)
@@ -15,8 +15,7 @@ struct B {
 int main () {
   B(10);       // expected-error {{functional-style cast from 'int' to 'B' is not allowed}}
   (B)10;       // expected-error {{C-style cast from 'int' to 'B' is not allowed}}
-  static_cast<B>(10);  // expected-error {{static_cast from 'int' to 'B' is not allowed}} \\
-                       // expected-warning {{expression result unused}}
+  static_cast<B>(10);  // expected-error {{static_cast from 'int' to 'B' is not allowed}}
 }
 
 template<class T>
index 9595faece29966478327d61227ab4e1cef67dd6e..631d1aafae2d1d3744291a79331752c2e9f8b180 100644 (file)
@@ -12,11 +12,11 @@ void f() {
   __typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}}
   void(a), ++a;
   if (int(a)+1) {}
-  for (int(a)+1;;) {} // expected-warning {{expression result unused}}
+  for (int(a)+1;;) {}
   a = sizeof(int()+1);
   a = sizeof(int(1));
   typeof(int()+1) a2; // expected-error {{extension used}}
-  (int(1)); // expected-warning {{expression result unused}}
+  (int(1));
 
   // type-id
   (int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
index a33ea5dede19e81945d22840baeabe6f95cdc324..09e0a5fa5ee7668a5096444d9f937567ed3fe964 100644 (file)
@@ -157,7 +157,7 @@ bool& operator,(X, Y);
 
 void test_comma(X x, Y y) {
   bool& b1 = (x, y);
-  X& xr = (x, x); // expected-warning {{expression result unused}}
+  X& xr = (x, x);
 }
 
 struct Callable {
index 6992cdcd0902a73299de5f4f005d3c4d152eef44..be992fa4074a2fda0ea8095cf580318787f2e4c5 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-value -verify %s
 template<typename T> void f() {
   T t;
   t = 17;
index 7a642fb10784767099b2f157f7d847c15e68c132..83ccf105df37aaa8b589d2e98384c28b3ca5f979 100644 (file)
@@ -9,7 +9,7 @@ void test1() {
 // This previously triggered a crash because the class has not been defined.
 @implementation RDar7495713 (rdar_7495713_cat)  // expected-error{{cannot find interface declaration for 'RDar7495713'}}
 - (id) rdar_7495713 {
-  __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
+  __PRETTY_FUNCTION__;
 }
 @end