summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2011-05-11 22:13:54 +0000
committerFrancois Pichet <pichet2000@gmail.com>2011-05-11 22:13:54 +0000
commitb796b632a848f617617ebc92ebd3e77c8343f0a7 (patch)
tree2bf3071105b17ad12c3a143d52c197a0a6524e9a /clang/lib/Sema/SemaCXXCast.cpp
parent2a9dbbbb12a018d254914368964c6c8745367f7d (diff)
downloadbcm5719-llvm-b796b632a848f617617ebc92ebd3e77c8343f0a7.tar.gz
bcm5719-llvm-b796b632a848f617617ebc92ebd3e77c8343f0a7.zip
In Microsoft mode, allow conversion from pointer to integral type no matter what size the integral type is. Necessary to parse MFC code.
Example: void f(char *ptr) { char var = (char)ptr; } llvm-svn: 131201
Diffstat (limited to 'clang/lib/Sema/SemaCXXCast.cpp')
-rw-r--r--clang/lib/Sema/SemaCXXCast.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp
index 2ea3b46829f..31a5f92dacc 100644
--- a/clang/lib/Sema/SemaCXXCast.cpp
+++ b/clang/lib/Sema/SemaCXXCast.cpp
@@ -1514,9 +1514,11 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr,
if (DestType->isIntegralType(Self.Context)) {
assert(srcIsPtr && "One type must be a pointer");
// C++ 5.2.10p4: A pointer can be explicitly converted to any integral
- // type large enough to hold it.
- if (Self.Context.getTypeSize(SrcType) >
- Self.Context.getTypeSize(DestType)) {
+ // type large enough to hold it; except in Microsoft mode, where the
+ // integral type size doesn't matter.
+ if ((Self.Context.getTypeSize(SrcType) >
+ Self.Context.getTypeSize(DestType)) &&
+ !Self.getLangOptions().Microsoft) {
msg = diag::err_bad_reinterpret_cast_small_int;
return TC_Failed;
}
OpenPOWER on IntegriCloud