diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-12-18 23:43:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-12-18 23:43:31 +0000 |
commit | dda78893c8d1f6f5cdcb19db58da11b756694e2c (patch) | |
tree | f05951b3799b853a576f53d7d2a0dc87c9c1a0ad /lib/Sema/SemaOverload.cpp | |
parent | 784606f796fa00427aab2f55c8e1025376450a17 (diff) |
Add some more implicit conversions for Objective-C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 5e3ec3f4bb..3671711964 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -846,6 +846,16 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType, return true; } + // Objective C++: Allow conversions between the Objective-C "id" and + // "Class", in either direction. + if ((Context.isObjCIdType(FromPointeeType) && + Context.isObjCClassType(ToPointeeType)) || + (Context.isObjCClassType(FromPointeeType) && + Context.isObjCIdType(ToPointeeType))) { + ConvertedType = ToType; + return true; + } + return false; } @@ -864,6 +874,16 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType) { /*DetectVirtual=*/false); QualType FromPointeeType = FromPtrType->getPointeeType(), ToPointeeType = ToPtrType->getPointeeType(); + + // Objective-C++ conversions are always okay. + // FIXME: We should have a different class of conversions for + // the Objective-C++ implicit conversions. + if (Context.isObjCIdType(FromPointeeType) || + Context.isObjCIdType(ToPointeeType) || + Context.isObjCClassType(FromPointeeType) || + Context.isObjCClassType(ToPointeeType)) + return false; + if (FromPointeeType->isRecordType() && ToPointeeType->isRecordType()) { // We must have a derived-to-base conversion. Check an |