[cfe-commits] r86891 - in /cfe/trunk: lib/Sema/Sema.cpp test/Sema/conversion.c
John McCall
rjmccall at apple.com
Wed Nov 11 14:52:37 PST 2009
Author: rjmccall
Date: Wed Nov 11 16:52:37 2009
New Revision: 86891
URL: http://llvm.org/viewvc/llvm-project?rev=86891&view=rev
Log:
Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part of
the -Wconversion check.
Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/Sema/conversion.c
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=86891&r1=86890&r2=86891&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Nov 11 16:52:37 2009
@@ -424,9 +424,15 @@
return true;
}
- assert(value.isComplexInt());
- return IsSameIntAfterCast(value.getComplexIntReal(), TargetWidth) &&
- IsSameIntAfterCast(value.getComplexIntImag(), TargetWidth);
+ if (value.isComplexInt()) {
+ return IsSameIntAfterCast(value.getComplexIntReal(), 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;
}
Modified: cfe/trunk/test/Sema/conversion.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conversion.c?rev=86891&r1=86890&r2=86891&view=diff
==============================================================================
--- cfe/trunk/test/Sema/conversion.c (original)
+++ cfe/trunk/test/Sema/conversion.c Wed Nov 11 16:52:37 2009
@@ -229,3 +229,9 @@
c = c + 1 + c * 2;
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}}
+}
More information about the cfe-commits
mailing list