summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-27 00:58:17 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-27 00:58:17 +0000
commit582813596a1005bf1bba2b6630f78a197f2e019b (patch)
tree385a36247405f8604d90479f76156fa748025e60 /clang/lib/Sema/SemaCXXCast.cpp
parent92b7077f9ebab1f499b1fa2216c07cdf2bb3a8b6 (diff)
downloadbcm5719-llvm-582813596a1005bf1bba2b6630f78a197f2e019b.tar.gz
bcm5719-llvm-582813596a1005bf1bba2b6630f78a197f2e019b.zip
Fix a horrible bug in our handling of C-style casting, where a C-style
derived-to-base cast that also casts away constness (one of the cases for static_cast followed by const_cast) would be treated as a bit-cast rather than a derived-to-base class, causing miscompiles and heartburn. Fixes <rdar://problem/8913298>. llvm-svn: 124340
Diffstat (limited to 'clang/lib/Sema/SemaCXXCast.cpp')
-rw-r--r--clang/lib/Sema/SemaCXXCast.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp
index c492c2ac7de..afbfa17e776 100644
--- a/clang/lib/Sema/SemaCXXCast.cpp
+++ b/clang/lib/Sema/SemaCXXCast.cpp
@@ -320,7 +320,7 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType) {
// Test if they're compatible.
return SrcConstruct != DestConstruct &&
- !Self.IsQualificationConversion(SrcConstruct, DestConstruct);
+ !Self.IsQualificationConversion(SrcConstruct, DestConstruct, false);
}
/// CheckDynamicCast - Check that a dynamic_cast\<DestType\>(SrcExpr) is valid.
@@ -1035,8 +1035,7 @@ TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
InitializedEntity Entity = InitializedEntity::InitializeTemporary(DestType);
InitializationKind InitKind
- = InitializationKind::CreateCast(/*FIXME:*/OpRange,
- CStyle);
+ = InitializationKind::CreateCast(/*FIXME:*/OpRange, CStyle);
InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExpr, 1);
// At this point of CheckStaticCast, if the destination is a reference,
OpenPOWER on IntegriCloud