]> granicus.if.org Git - clang/commitdiff
Ignore void returning overloaded functions fom -Wunused-comparison. PR19791.
authorRichard Trieu <rtrieu@google.com>
Tue, 20 May 2014 01:34:43 +0000 (01:34 +0000)
committerRichard Trieu <rtrieu@google.com>
Tue, 20 May 2014 01:34:43 +0000 (01:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209186 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/SemaCXX/warn-unused-comparison.cpp

index f51e188b41676416a7aeeb8a03e50b8df18e4f41..aea2f432ad5e1822409ae268e33e16aa30eb4627 100644 (file)
@@ -2094,7 +2094,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
     case OO_Greater:
     case OO_GreaterEqual:
     case OO_LessEqual:
-      if (Op->getCallReturnType()->isReferenceType())
+      if (Op->getCallReturnType()->isReferenceType() ||
+          Op->getCallReturnType()->isVoidType())
         break;
       WarnE = this;
       Loc = Op->getOperatorLoc();
index 4dd203875b35c023d31cb87ca3eaf9cd571f02d0..3afad585b668936f85486a5d7fd585ac5898bff3 100644 (file)
@@ -119,3 +119,17 @@ void test() {
   cout < cin;  // expected-warning {{relational comparison result unused}}
 }
 }
+
+namespace PR19791 {
+struct S {
+  void operator!=(int);
+  int operator==(int);
+};
+
+void test() {
+  S s;
+  s != 1;
+  s == 1;  // expected-warning{{equality comparison result unused}}
+           // expected-note@-1{{use '=' to turn this equality comparison into an assignment}}
+}
+}