From: Ted Kremenek Date: Wed, 5 Mar 2014 22:32:39 +0000 (+0000) Subject: [-Wunreachable-code] generalize configuration value checking to all comparison operators. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6e164986a074d181cc7db5c947421d749f96a30;p=clang [-Wunreachable-code] generalize configuration value checking to all comparison operators. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203016 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index 5baaa00677..f159642db2 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -382,7 +382,7 @@ static bool isConfigurationValue(const Stmt *S) { return true; case Stmt::BinaryOperatorClass: { const BinaryOperator *B = cast(S); - return (B->isLogicalOp() || B->isRelationalOp()) && + return (B->isLogicalOp() || B->isComparisonOp()) && (isConfigurationValue(B->getLHS()) || isConfigurationValue(B->getRHS())); } diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c index b2448e9878..e8089aaa4f 100644 --- a/test/Sema/warn-unreachable.c +++ b/test/Sema/warn-unreachable.c @@ -226,3 +226,11 @@ int test_config_constant(int x) { calledFun(); // expected-warning {{will never be executed}} } +int sizeof_int() { + if (sizeof(long) == sizeof(int)) + return 1; // no-warning + if (sizeof(long) != sizeof(int)) + return 0; // no-warning + return 2; // no-warning +} +