Skip to content
Snippets Groups Projects
Commit 1469f398 authored by Richard Trieu's avatar Richard Trieu
Browse files

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209186 91177308-0d34-0410-b5e6-96231b3b80d8
parent ea6edcb4
No related branches found
No related tags found
No related merge requests found
...@@ -2094,7 +2094,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, ...@@ -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();
......
...@@ -119,3 +119,17 @@ void test() { ...@@ -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}}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment