]> granicus.if.org Git - clang/commitdiff
Make the "unused result" warning a warning about run-time behavior, so
authorDouglas Gregor <dgregor@apple.com>
Thu, 15 Jul 2010 18:47:04 +0000 (18:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 15 Jul 2010 18:47:04 +0000 (18:47 +0000)
that we don't warn when there isn't going to be any computation anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108442 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmt.cpp
test/Sema/const-eval.c
test/Sema/expr-comma-c89.c
test/Sema/expr-comma.c
test/SemaCXX/decltype.cpp

index 9c8f48bfea17276535267ef5b7f611d9321a23b6..075f662824708fef22c3426f82f432174cd6ec8b 100644 (file)
@@ -141,7 +141,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
     }
   }
 
-  Diag(Loc, DiagID) << R1 << R2;
+  DiagRuntimeBehavior(Loc, PDiag(DiagID) << R1 << R2);
 }
 
 Action::OwningStmtResult
index c132b347d7b2dc8d7b0935cfc7b52cd881348590..9c537250a93a067e284370692b01825b6f526aa9 100644 (file)
@@ -74,5 +74,5 @@ const _Bool constbool = 0;
 EVAL_EXPR(35, constbool)
 EVAL_EXPR(36, constbool)
 
-EVAL_EXPR(37, (1,2.0) == 2.0)  // expected-warning {{expression result unused}}
+EVAL_EXPR(37, (1,2.0) == 2.0)
 EVAL_EXPR(38, __builtin_expect(1,1) == 1)
index dc427028d0d1bfdecfb067de334b56611d32dc98..d0883ba202f9b4309cdf8f177ee392bd2d0db6f7 100644 (file)
@@ -11,7 +11,7 @@ int B[sizeof((a.c)) == 17 ? 1 : -1];
 
 
 // comma does array/function promotion in c99.
-int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}}
-int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1];   // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
-int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1];  // expected-warning {{expression result unused}}
+int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1];
+int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1];
+int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1];
 
index b004fc1ba3e29547c860302b9fcbd2c8b5dbf64a..d3e4020af637f850a5c9032f4138ef9caf064cfd 100644 (file)
@@ -11,7 +11,7 @@ int B[sizeof((a.c)) == 17 ? 1 : -1];
 
 
 // comma does not promote array/function in c90 unless they are lvalues.
-int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1];  // expected-warning {{expression result unused}}
-int X[sizeof(0, (foo().c)) == 17 ? 1 : -1];              // expected-warning {{expression result unused}}
-int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1];   // expected-warning {{expression result unused}} // expected-warning {{expression result unused}}
-int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1];   // expected-warning {{expression result unused}}
+int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1];
+int X[sizeof(0, (foo().c)) == 17 ? 1 : -1];
+int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1];
+int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1];
index b6bcd043f3201a1f05d34ab0b406c499f3928af7..d4ef7e33a1d1a3280462b8f4c04a37e799b3fad7 100644 (file)
@@ -3,7 +3,7 @@
 // PR5290
 int const f0();
 void f0_test() {
-  decltype(0, f0()) i = 0; // expected-warning{{expression result unused}}
+  decltype(0, f0()) i = 0;
   i = 0;
 }