diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-01-07 22:18:05 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-01-07 22:18:05 +0000 |
commit | 07c0f285ba92148f5793959c386dc2ba8f0cc7f7 (patch) | |
tree | 964b85fb29ee7613ed394bb8fe656d16945b4e23 /clang/lib | |
parent | e15bffe9ea8743182f70f18d1a8720c21d28be18 (diff) | |
download | bcm5719-llvm-07c0f285ba92148f5793959c386dc2ba8f0cc7f7.tar.gz bcm5719-llvm-07c0f285ba92148f5793959c386dc2ba8f0cc7f7.zip |
Fix a couple of wrong self-comparison diagnostics.
Check whether we are comparing the same entity, not merely the same
declaration, and don't assume that weak declarations resolve to distinct
entities.
llvm-svn: 321976
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 933289360b2..e9e65fc1fc5 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -9627,7 +9627,8 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, // result. ValueDecl *DL = getCompareDecl(LHSStripped); ValueDecl *DR = getCompareDecl(RHSStripped); - if (DL && DR && DL == DR && !IsWithinTemplateSpecialization(DL)) { + if (DL && DR && declaresSameEntity(DL, DR) && + !IsWithinTemplateSpecialization(DL)) { StringRef Result; switch (Opc) { case BO_EQ: case BO_LE: case BO_GE: @@ -9648,10 +9649,9 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, << Result); } else if (DL && DR && LHSType->isArrayType() && RHSType->isArrayType() && !DL->getType()->isReferenceType() && - !DR->getType()->isReferenceType()) { + !DR->getType()->isReferenceType() && + !DL->isWeak() && !DR->isWeak()) { // What is it always going to evaluate to? - // FIXME: This is wrong if DL and DR are different Decls for the same - // entity. It's also wrong if DL and/or DR are weak declarations. StringRef Result; switch(Opc) { case BO_EQ: // e.g. array1 == array2 |