Ignore void returning overloaded functions fom -Wunused-comparison. PR19791.

llvm-svn: 209186
This commit is contained in:
Richard Trieu 2014-05-20 01:34:43 +00:00
parent d52b1528c0
commit ccedd52736
2 changed files with 16 additions and 1 deletions

View File

@ -2094,7 +2094,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
case OO_Greater: case OO_Greater:
case OO_GreaterEqual: case OO_GreaterEqual:
case OO_LessEqual: case OO_LessEqual:
if (Op->getCallReturnType()->isReferenceType()) if (Op->getCallReturnType()->isReferenceType() ||
Op->getCallReturnType()->isVoidType())
break; break;
WarnE = this; WarnE = this;
Loc = Op->getOperatorLoc(); Loc = Op->getOperatorLoc();

View File

@ -119,3 +119,17 @@ void test() {
cout < cin; // expected-warning {{relational comparison result unused}} 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}}
}
}