diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2017-09-20 13:50:01 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2017-09-20 13:50:01 +0000 |
commit | 30d26086372cfb99b0829e676d075f95e2b9c35a (patch) | |
tree | 699689c3e5e0d2d365a0743dbe4037429dcfa973 /clang/lib/Sema/SemaChecking.cpp | |
parent | d202ad15c11950c71b8379ae3e2db4892b5d9d7b (diff) | |
download | bcm5719-llvm-30d26086372cfb99b0829e676d075f95e2b9c35a.tar.gz bcm5719-llvm-30d26086372cfb99b0829e676d075f95e2b9c35a.zip |
Replace r313747, don't always warn on enums, rework testcases.
As Aaron Ballman has pointed out, that is not really correct.
So the key problem there is the invalidity of the testcase.
Revert r313747, and rework testcase in such a way, so these
details (platform-specific default enum sigdness) are
accounted for.
Also, add a C++-specific testcase.
llvm-svn: 313756
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 9ff8f6347e7..87634ad57e5 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -8592,26 +8592,22 @@ bool CheckTautologicalComparisonWithZero(Sema &S, BinaryOperator *E) { bool Match = true; - if (Op == BO_LT && IsZero(S, RHS) && - (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) { + if (Op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) { S.Diag(E->getOperatorLoc(), HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison : diag::warn_lunsigned_always_true_comparison) << "< 0" << false << LHS->getSourceRange() << RHS->getSourceRange(); - } else if (Op == BO_GE && IsZero(S, RHS) && - (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) { + } else if (Op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) { S.Diag(E->getOperatorLoc(), HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison : diag::warn_lunsigned_always_true_comparison) << ">= 0" << true << LHS->getSourceRange() << RHS->getSourceRange(); - } else if (Op == BO_GT && IsZero(S, LHS) && - (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) { + } else if (Op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) { S.Diag(E->getOperatorLoc(), HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison : diag::warn_runsigned_always_true_comparison) << "0 >" << false << LHS->getSourceRange() << RHS->getSourceRange(); - } else if (Op == BO_LE && IsZero(S, LHS) && - (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) { + } else if (Op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) { S.Diag(E->getOperatorLoc(), HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison : diag::warn_runsigned_always_true_comparison) |