forked from OSchip/llvm-project
Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part of
the -Wconversion check. llvm-svn: 86891
This commit is contained in:
parent
d708eb6b6a
commit
5055e4cdfd
|
@ -424,9 +424,15 @@ static bool IsSameIntAfterCast(const APValue &value, unsigned TargetWidth) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(value.isComplexInt());
|
if (value.isComplexInt()) {
|
||||||
return IsSameIntAfterCast(value.getComplexIntReal(), TargetWidth) &&
|
return IsSameIntAfterCast(value.getComplexIntReal(), TargetWidth) &&
|
||||||
IsSameIntAfterCast(value.getComplexIntImag(), TargetWidth);
|
IsSameIntAfterCast(value.getComplexIntImag(), TargetWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This can happen with lossless casts to intptr_t of "based" lvalues.
|
||||||
|
// Assume it might use arbitrary bits.
|
||||||
|
assert(value.isLValue());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -229,3 +229,9 @@ void test15(char c) {
|
||||||
c = c + 1 + c * 2;
|
c = c + 1 + c * 2;
|
||||||
c = (short) c + 1 + c * 2; // expected-warning {{implicit cast loses integer precision}}
|
c = (short) c + 1 + c * 2; // expected-warning {{implicit cast loses integer precision}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PR 5422
|
||||||
|
extern void *test16_external;
|
||||||
|
void test16(void) {
|
||||||
|
int a = (unsigned long) &test16_external; // expected-warning {{implicit cast loses integer precision}}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue