forked from OSchip/llvm-project
Improvements to my patch in r164143 per
Richard's comments. // rdar://12202422 llvm-svn: 164316
This commit is contained in:
parent
85568adcee
commit
2f4e33aba2
|
@ -195,8 +195,9 @@ def : DiagGroup<"synth">;
|
|||
def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
|
||||
def StringPlusInt : DiagGroup<"string-plus-int">;
|
||||
def StrncatSize : DiagGroup<"strncat-size">;
|
||||
def TautologicalCompare : DiagGroup<"tautological-compare">;
|
||||
def TautologicalOutofRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
|
||||
def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
|
||||
def TautologicalCompare : DiagGroup<"tautological-compare",
|
||||
[TautologicalOutOfRangeCompare]>;
|
||||
def HeaderHygiene : DiagGroup<"header-hygiene">;
|
||||
def DuplicateDeclSpecifier : DiagGroup<"duplicate-decl-specifier">;
|
||||
|
||||
|
|
|
@ -4070,9 +4070,9 @@ def warn_mixed_sign_comparison : Warning<
|
|||
def warn_lunsigned_always_true_comparison : Warning<
|
||||
"comparison of unsigned%select{| enum}2 expression %0 is always %1">,
|
||||
InGroup<TautologicalCompare>;
|
||||
def warn_outof_range_compare : Warning<
|
||||
"comparison of literal %0 with expression of type %1 is always "
|
||||
"%select{false|true}2">, InGroup<TautologicalOutofRangeCompare>;
|
||||
def warn_out_of_range_compare : Warning<
|
||||
"comparison of constant %0 with expression of type %1 is always "
|
||||
"%select{false|true}2">, InGroup<TautologicalOutOfRangeCompare>;
|
||||
def warn_runsigned_always_true_comparison : Warning<
|
||||
"comparison of %0 unsigned%select{| enum}2 expression is always %1">,
|
||||
InGroup<TautologicalCompare>;
|
||||
|
|
|
@ -4302,41 +4302,40 @@ static void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) {
|
|||
}
|
||||
|
||||
static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E,
|
||||
Expr *lit, Expr *other,
|
||||
Expr *Constant, Expr *Other,
|
||||
llvm::APSInt Value,
|
||||
bool rhsLiteral) {
|
||||
bool RhsConstant) {
|
||||
BinaryOperatorKind op = E->getOpcode();
|
||||
QualType OtherT = other->getType();
|
||||
const Type *OtherPtrT = S.Context.getCanonicalType(OtherT).getTypePtr();
|
||||
const Type *LitPtrT = S.Context.getCanonicalType(lit->getType()).getTypePtr();
|
||||
if (OtherPtrT == LitPtrT)
|
||||
QualType OtherT = Other->getType();
|
||||
QualType ConstantT = Constant->getType();
|
||||
if (S.Context.hasSameUnqualifiedType(OtherT, ConstantT))
|
||||
return;
|
||||
assert((OtherT->isIntegerType() && LitPtrT->isIntegerType())
|
||||
assert((OtherT->isIntegerType() && ConstantT->isIntegerType())
|
||||
&& "comparison with non-integer type");
|
||||
// FIXME. handle cases for signedness to catch (signed char)N == 200
|
||||
IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
|
||||
IntRange LitRange = GetExprRange(S.Context, lit);
|
||||
IntRange LitRange = GetValueRange(S.Context, Value, Value.getBitWidth());
|
||||
if (OtherRange.Width >= LitRange.Width)
|
||||
return;
|
||||
std::string PrettySourceValue = Value.toString(10);
|
||||
bool IsTrue = true;
|
||||
if (op == BO_EQ)
|
||||
IsTrue = false;
|
||||
else if (op == BO_NE)
|
||||
IsTrue = true;
|
||||
else if (rhsLiteral) {
|
||||
else if (RhsConstant) {
|
||||
if (op == BO_GT || op == BO_GE)
|
||||
IsTrue = !LitRange.NonNegative;
|
||||
else // op == BO_LT || op == BO_LE
|
||||
IsTrue = LitRange.NonNegative;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (op == BO_LT || op == BO_LE)
|
||||
IsTrue = !LitRange.NonNegative;
|
||||
else // op == BO_GT || op == BO_GE
|
||||
IsTrue = LitRange.NonNegative;
|
||||
}
|
||||
S.Diag(E->getOperatorLoc(), diag::warn_outof_range_compare)
|
||||
<< PrettySourceValue << other->getType() << IsTrue
|
||||
SmallString<16> PrettySourceValue(Value.toString(10));
|
||||
S.Diag(E->getOperatorLoc(), diag::warn_out_of_range_compare)
|
||||
<< PrettySourceValue << OtherT << IsTrue
|
||||
<< E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
|
||||
}
|
||||
|
||||
|
@ -4363,7 +4362,7 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) {
|
|||
|
||||
bool IsComparisonConstant = false;
|
||||
|
||||
// Check that an integer constant comparison results in a value
|
||||
// Check whether an integer constant comparison results in a value
|
||||
// of 'true' or 'false'.
|
||||
if (T->isIntegralType(S.Context)) {
|
||||
llvm::APSInt RHSValue;
|
||||
|
@ -4379,8 +4378,7 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) {
|
|||
else
|
||||
IsComparisonConstant =
|
||||
(IsRHSIntegralLiteral && IsLHSIntegralLiteral);
|
||||
}
|
||||
else if (!T->hasUnsignedIntegerRepresentation())
|
||||
} else if (!T->hasUnsignedIntegerRepresentation())
|
||||
IsComparisonConstant = E->isIntegerConstantExpr(S.Context);
|
||||
|
||||
// We don't do anything special if this isn't an unsigned integral
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range -Wno-tautological-compare %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range -Wno-tautological-compare -Wtautological-constant-out-of-range-compare %s
|
||||
|
||||
void clang_analyzer_eval(bool);
|
||||
|
||||
|
@ -128,10 +128,10 @@ void tautologies(unsigned a) {
|
|||
|
||||
// Tautologies from outside the range of the symbol
|
||||
void tautologiesOutside(unsigned char a) {
|
||||
clang_analyzer_eval(a <= 0x100); // expected-warning{{comparison of literal 256 with expression of type 'unsigned char' is always true}} expected-warning{{TRUE}}
|
||||
clang_analyzer_eval(a < 0x100); // expected-warning{{comparison of literal 256 with expression of type 'unsigned char' is always true}} expected-warning{{TRUE}}
|
||||
clang_analyzer_eval(a <= 0x100); // expected-warning{{comparison of constant 256 with expression of type 'unsigned char' is always true}} expected-warning{{TRUE}}
|
||||
clang_analyzer_eval(a < 0x100); // expected-warning{{comparison of constant 256 with expression of type 'unsigned char' is always true}} expected-warning{{TRUE}}
|
||||
|
||||
clang_analyzer_eval(a != 0x100); // expected-warning{{comparison of literal 256 with expression of type 'unsigned char' is always true}} expected-warning{{TRUE}}
|
||||
clang_analyzer_eval(a != 0x100); // expected-warning{{comparison of constant 256 with expression of type 'unsigned char' is always true}} expected-warning{{TRUE}}
|
||||
clang_analyzer_eval(a != -1); // expected-warning{{TRUE}}
|
||||
|
||||
clang_analyzer_eval(a > -1); // expected-warning{{TRUE}}
|
||||
|
|
|
@ -93,8 +93,8 @@ int ints(long a, unsigned long b) {
|
|||
// (C,b)
|
||||
(C == (unsigned long) b) +
|
||||
(C == (unsigned int) b) +
|
||||
(C == (unsigned short) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C == (unsigned char) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned char' is always false}}
|
||||
(C == (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C == (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
|
||||
((long) C == b) +
|
||||
((int) C == b) +
|
||||
((short) C == b) +
|
||||
|
@ -105,8 +105,8 @@ int ints(long a, unsigned long b) {
|
|||
((signed char) C == (unsigned char) b) +
|
||||
(C < (unsigned long) b) +
|
||||
(C < (unsigned int) b) +
|
||||
(C < (unsigned short) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C < (unsigned char) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned char' is always false}}
|
||||
(C < (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C < (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
|
||||
((long) C < b) +
|
||||
((int) C < b) +
|
||||
((short) C < b) +
|
||||
|
@ -123,8 +123,8 @@ int ints(long a, unsigned long b) {
|
|||
(a == (unsigned char) C) +
|
||||
((long) a == C) +
|
||||
((int) a == C) +
|
||||
((short) a == C) + // expected-warning {{comparison of literal 65536 with expression of type 'short' is always false}}
|
||||
((signed char) a == C) + // expected-warning {{comparison of literal 65536 with expression of type 'signed char' is always false}}
|
||||
((short) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always false}}
|
||||
((signed char) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always false}}
|
||||
((long) a == (unsigned long) C) +
|
||||
((int) a == (unsigned int) C) +
|
||||
((short) a == (unsigned short) C) +
|
||||
|
@ -135,8 +135,8 @@ int ints(long a, unsigned long b) {
|
|||
(a < (unsigned char) C) +
|
||||
((long) a < C) +
|
||||
((int) a < C) +
|
||||
((short) a < C) + // expected-warning {{comparison of literal 65536 with expression of type 'short' is always true}}
|
||||
((signed char) a < C) + // expected-warning {{comparison of literal 65536 with expression of type 'signed char' is always true}}
|
||||
((short) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always true}}
|
||||
((signed char) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always true}}
|
||||
((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
|
||||
((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
|
||||
((short) a < (unsigned short) C) +
|
||||
|
@ -145,8 +145,8 @@ int ints(long a, unsigned long b) {
|
|||
// (0x80000,b)
|
||||
(0x80000 == (unsigned long) b) +
|
||||
(0x80000 == (unsigned int) b) +
|
||||
(0x80000 == (unsigned short) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 == (unsigned char) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned char' is always false}}
|
||||
(0x80000 == (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 == (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
|
||||
((long) 0x80000 == b) +
|
||||
((int) 0x80000 == b) +
|
||||
((short) 0x80000 == b) +
|
||||
|
@ -157,8 +157,8 @@ int ints(long a, unsigned long b) {
|
|||
((signed char) 0x80000 == (unsigned char) b) +
|
||||
(0x80000 < (unsigned long) b) +
|
||||
(0x80000 < (unsigned int) b) +
|
||||
(0x80000 < (unsigned short) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 < (unsigned char) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned char' is always false}}
|
||||
(0x80000 < (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 < (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
|
||||
((long) 0x80000 < b) +
|
||||
((int) 0x80000 < b) +
|
||||
((short) 0x80000 < b) +
|
||||
|
@ -175,8 +175,8 @@ int ints(long a, unsigned long b) {
|
|||
(a == (unsigned char) 0x80000) +
|
||||
((long) a == 0x80000) +
|
||||
((int) a == 0x80000) +
|
||||
((short) a == 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'short' is always false}}
|
||||
((signed char) a == 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'signed char' is always false}}
|
||||
((short) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always false}}
|
||||
((signed char) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always false}}
|
||||
((long) a == (unsigned long) 0x80000) +
|
||||
((int) a == (unsigned int) 0x80000) +
|
||||
((short) a == (unsigned short) 0x80000) +
|
||||
|
@ -187,8 +187,8 @@ int ints(long a, unsigned long b) {
|
|||
(a < (unsigned char) 0x80000) +
|
||||
((long) a < 0x80000) +
|
||||
((int) a < 0x80000) +
|
||||
((short) a < 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'short' is always true}}
|
||||
((signed char) a < 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'signed char' is always true}}
|
||||
((short) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always true}}
|
||||
((signed char) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always true}}
|
||||
((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
|
||||
((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
|
||||
((short) a < (unsigned short) 0x80000) +
|
||||
|
|
|
@ -6,42 +6,42 @@ int value(void);
|
|||
int main()
|
||||
{
|
||||
int a = value();
|
||||
if (a == 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (a != 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (a != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (a < 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (a < 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (a <= 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (a <= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (a > 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a > 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (a >= 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a >= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
|
||||
if (0x1234567812345678L == a) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (0x1234567812345678L == a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (0x1234567812345678L != a) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (0x1234567812345678L != a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (0x1234567812345678L < a) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (0x1234567812345678L < a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (0x1234567812345678L <= a) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (0x1234567812345678L <= a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (0x1234567812345678L > a) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (0x1234567812345678L > a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (0x1234567812345678L >= a) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (0x1234567812345678L >= a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (a == 0x1234567812345678LL) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a == 0x1234567812345678LL) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (a == -0x1234567812345678L) // expected-warning {{comparison of literal -1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a == -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (a < -0x1234567812345678L) // expected-warning {{comparison of literal -1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a < -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (a > -0x1234567812345678L) // expected-warning {{comparison of literal -1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (a > -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
if (a <= -0x1234567812345678L) // expected-warning {{comparison of literal -1311768465173141112 with expression of type 'int' is always false}}
|
||||
if (a <= -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
|
||||
return 0;
|
||||
if (a >= -0x1234567812345678L) // expected-warning {{comparison of literal -1311768465173141112 with expression of type 'int' is always true}}
|
||||
if (a >= -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always true}}
|
||||
return 0;
|
||||
|
||||
|
||||
|
@ -49,30 +49,30 @@ int main()
|
|||
return 1;
|
||||
|
||||
short s = value();
|
||||
if (s == 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always false}}
|
||||
if (s == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
||||
return 0;
|
||||
if (s != 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always true}}
|
||||
if (s != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
||||
return 0;
|
||||
if (s < 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always true}}
|
||||
if (s < 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
||||
return 0;
|
||||
if (s <= 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always true}}
|
||||
if (s <= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
||||
return 0;
|
||||
if (s > 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always false}}
|
||||
if (s > 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
||||
return 0;
|
||||
if (s >= 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always false}}
|
||||
if (s >= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
||||
return 0;
|
||||
|
||||
if (0x1234567812345678L == s) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always false}}
|
||||
if (0x1234567812345678L == s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
||||
return 0;
|
||||
if (0x1234567812345678L != s) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always true}}
|
||||
if (0x1234567812345678L != s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
||||
return 0;
|
||||
if (0x1234567812345678L < s) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always false}}
|
||||
if (0x1234567812345678L < s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
||||
return 0;
|
||||
if (0x1234567812345678L <= s) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always false}}
|
||||
if (0x1234567812345678L <= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
|
||||
return 0;
|
||||
if (0x1234567812345678L > s) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always true}}
|
||||
if (0x1234567812345678L > s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
||||
return 0;
|
||||
if (0x1234567812345678L >= s) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'short' is always true}}
|
||||
if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
|
||||
return 0;
|
||||
long l = value();
|
||||
if (l == 0x1234567812345678L)
|
||||
|
@ -142,7 +142,7 @@ int main()
|
|||
};
|
||||
enum E e;
|
||||
|
||||
if (e == 0x1234567812345678L) // expected-warning {{comparison of literal 1311768465173141112 with expression of type 'enum E' is always false}}
|
||||
if (e == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'enum E' is always false}}
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -89,8 +89,8 @@ int test0(long a, unsigned long b) {
|
|||
// (C,b)
|
||||
(C == (unsigned long) b) +
|
||||
(C == (unsigned int) b) +
|
||||
(C == (unsigned short) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C == (unsigned char) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned char' is always false}}
|
||||
(C == (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C == (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
|
||||
((long) C == b) +
|
||||
((int) C == b) +
|
||||
((short) C == b) +
|
||||
|
@ -101,8 +101,8 @@ int test0(long a, unsigned long b) {
|
|||
((signed char) C == (unsigned char) b) +
|
||||
(C < (unsigned long) b) +
|
||||
(C < (unsigned int) b) +
|
||||
(C < (unsigned short) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C < (unsigned char) b) + // expected-warning {{comparison of literal 65536 with expression of type 'unsigned char' is always false}}
|
||||
(C < (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
|
||||
(C < (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
|
||||
((long) C < b) +
|
||||
((int) C < b) +
|
||||
((short) C < b) +
|
||||
|
@ -119,8 +119,8 @@ int test0(long a, unsigned long b) {
|
|||
(a == (unsigned char) C) +
|
||||
((long) a == C) +
|
||||
((int) a == C) +
|
||||
((short) a == C) + // expected-warning {{comparison of literal 65536 with expression of type 'short' is always false}}
|
||||
((signed char) a == C) + // expected-warning {{comparison of literal 65536 with expression of type 'signed char' is always false}}
|
||||
((short) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always false}}
|
||||
((signed char) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always false}}
|
||||
((long) a == (unsigned long) C) +
|
||||
((int) a == (unsigned int) C) +
|
||||
((short) a == (unsigned short) C) +
|
||||
|
@ -131,8 +131,8 @@ int test0(long a, unsigned long b) {
|
|||
(a < (unsigned char) C) +
|
||||
((long) a < C) +
|
||||
((int) a < C) +
|
||||
((short) a < C) + // expected-warning {{comparison of literal 65536 with expression of type 'short' is always true}}
|
||||
((signed char) a < C) + // expected-warning {{comparison of literal 65536 with expression of type 'signed char' is always true}}
|
||||
((short) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always true}}
|
||||
((signed char) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always true}}
|
||||
((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
|
||||
((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
|
||||
((short) a < (unsigned short) C) +
|
||||
|
@ -141,8 +141,8 @@ int test0(long a, unsigned long b) {
|
|||
// (0x80000,b)
|
||||
(0x80000 == (unsigned long) b) +
|
||||
(0x80000 == (unsigned int) b) +
|
||||
(0x80000 == (unsigned short) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 == (unsigned char) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned char' is always false}}
|
||||
(0x80000 == (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 == (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
|
||||
((long) 0x80000 == b) +
|
||||
((int) 0x80000 == b) +
|
||||
((short) 0x80000 == b) +
|
||||
|
@ -153,8 +153,8 @@ int test0(long a, unsigned long b) {
|
|||
((signed char) 0x80000 == (unsigned char) b) +
|
||||
(0x80000 < (unsigned long) b) +
|
||||
(0x80000 < (unsigned int) b) +
|
||||
(0x80000 < (unsigned short) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 < (unsigned char) b) + // expected-warning {{comparison of literal 524288 with expression of type 'unsigned char' is always false}}
|
||||
(0x80000 < (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
|
||||
(0x80000 < (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
|
||||
((long) 0x80000 < b) +
|
||||
((int) 0x80000 < b) +
|
||||
((short) 0x80000 < b) +
|
||||
|
@ -171,8 +171,8 @@ int test0(long a, unsigned long b) {
|
|||
(a == (unsigned char) 0x80000) +
|
||||
((long) a == 0x80000) +
|
||||
((int) a == 0x80000) +
|
||||
((short) a == 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'short' is always false}}
|
||||
((signed char) a == 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'signed char' is always false}}
|
||||
((short) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always false}}
|
||||
((signed char) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always false}}
|
||||
((long) a == (unsigned long) 0x80000) +
|
||||
((int) a == (unsigned int) 0x80000) +
|
||||
((short) a == (unsigned short) 0x80000) +
|
||||
|
@ -183,8 +183,8 @@ int test0(long a, unsigned long b) {
|
|||
(a < (unsigned char) 0x80000) +
|
||||
((long) a < 0x80000) +
|
||||
((int) a < 0x80000) +
|
||||
((short) a < 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'short' is always true}}
|
||||
((signed char) a < 0x80000) + // expected-warning {{comparison of literal 524288 with expression of type 'signed char' is always true}}
|
||||
((short) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always true}}
|
||||
((signed char) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always true}}
|
||||
((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
|
||||
((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
|
||||
((short) a < (unsigned short) 0x80000) +
|
||||
|
|
|
@ -39,8 +39,8 @@ void test () {
|
|||
while (b == c);
|
||||
while (B1 == name1::B2);
|
||||
while (B2 == name2::B1);
|
||||
while (x == AnonAA); // expected-warning {{comparison of literal 42 with expression of type 'Foo' is always false}}
|
||||
while (AnonBB == y); // expected-warning {{comparison of literal 45 with expression of type 'Bar' is always false}}
|
||||
while (x == AnonAA); // expected-warning {{comparison of constant 42 with expression of type 'Foo' is always false}}
|
||||
while (AnonBB == y); // expected-warning {{comparison of constant 45 with expression of type 'Bar' is always false}}
|
||||
while (AnonAA == AnonAB);
|
||||
while (AnonAB == AnonBA);
|
||||
while (AnonBB == AnonAA);
|
||||
|
|
Loading…
Reference in New Issue