When an overloaded comparison operator returns a reference, do not consider
it for -Wunused-comparion warnings. This fixes PR19724. llvm-svn: 208824
This commit is contained in:
parent
73bd03cee9
commit
161132b95b
|
@ -2094,6 +2094,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
|
|||
case OO_Greater:
|
||||
case OO_GreaterEqual:
|
||||
case OO_LessEqual:
|
||||
if (Op->getCallReturnType()->isReferenceType())
|
||||
break;
|
||||
WarnE = this;
|
||||
Loc = Op->getOperatorLoc();
|
||||
R1 = Op->getSourceRange();
|
||||
|
|
|
@ -106,3 +106,16 @@ namespace PR10291 {
|
|||
|
||||
X<int> x;
|
||||
}
|
||||
|
||||
namespace PR19724 {
|
||||
class stream {
|
||||
} cout, cin;
|
||||
|
||||
stream &operator<(stream &s, int);
|
||||
bool operator<(stream &s, stream &s2);
|
||||
|
||||
void test() {
|
||||
cout < 5; // no waring, operator returns a reference
|
||||
cout < cin; // expected-warning {{relational comparison result unused}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue