[cfe-commits] r81608 - in /cfe/trunk/lib/Sema: Sema.h SemaExprCXX.cpp SemaOverload.cpp

Anders Carlsson andersca at mac.com
Fri Sep 11 21:46:44 PDT 2009


Author: andersca
Date: Fri Sep 11 23:46:44 2009
New Revision: 81608

URL: http://llvm.org/viewvc/llvm-project?rev=81608&view=rev
Log:
Use the correct CastKind for derived-to-base pointer conversions.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=81608&r1=81607&r2=81608&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Sep 11 23:46:44 2009
@@ -763,7 +763,8 @@
                            QualType& ConvertedType, bool &IncompatibleObjC);
   bool isObjCPointerConversion(QualType FromType, QualType ToType,
                                QualType& ConvertedType, bool &IncompatibleObjC);
-  bool CheckPointerConversion(Expr *From, QualType ToType);
+  bool CheckPointerConversion(Expr *From, QualType ToType, 
+                              CastExpr::CastKind &Kind);
   bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
                                  QualType &ConvertedType);
   bool CheckMemberPointerConversion(Expr *From, QualType ToType,

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=81608&r1=81607&r2=81608&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 11 23:46:44 2009
@@ -1094,7 +1094,7 @@
     ImpCastExprToType(From, FromType);
     break;
 
-  case ICK_Pointer_Conversion:
+  case ICK_Pointer_Conversion: {
     if (SCS.IncompatibleObjC) {
       // Diagnose incompatible Objective-C conversions
       Diag(From->getSourceRange().getBegin(),
@@ -1103,18 +1103,21 @@
         << From->getSourceRange();
     }
 
-    if (CheckPointerConversion(From, ToType))
+    
+    CastExpr::CastKind Kind = CastExpr::CK_Unknown;
+    if (CheckPointerConversion(From, ToType, Kind))
       return true;
-    ImpCastExprToType(From, ToType);
+    ImpCastExprToType(From, ToType, Kind);
     break;
-
-    case ICK_Pointer_Member: {
-      CastExpr::CastKind Kind = CastExpr::CK_Unknown;
-      if (CheckMemberPointerConversion(From, ToType, Kind))
-        return true;
-      ImpCastExprToType(From, ToType, Kind);
-      break;
-    }
+  }
+  
+  case ICK_Pointer_Member: {
+    CastExpr::CastKind Kind = CastExpr::CK_Unknown;
+    if (CheckMemberPointerConversion(From, ToType, Kind))
+      return true;
+    ImpCastExprToType(From, ToType, Kind);
+    break;
+  }
   case ICK_Boolean_Conversion:
     FromType = Context.BoolTy;
     ImpCastExprToType(From, FromType);

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=81608&r1=81607&r2=81608&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Sep 11 23:46:44 2009
@@ -1135,7 +1135,8 @@
 /// conversions for which IsPointerConversion has already returned
 /// true. It returns true and produces a diagnostic if there was an
 /// error, or returns false otherwise.
-bool Sema::CheckPointerConversion(Expr *From, QualType ToType) {
+bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
+                                  CastExpr::CastKind &Kind) {
   QualType FromType = From->getType();
 
   if (const PointerType *FromPtrType = FromType->getAs<PointerType>())
@@ -1147,9 +1148,13 @@
           ToPointeeType->isRecordType()) {
         // We must have a derived-to-base conversion. Check an
         // ambiguous or inaccessible conversion.
-        return CheckDerivedToBaseConversion(FromPointeeType, ToPointeeType,
-                                            From->getExprLoc(),
-                                            From->getSourceRange());
+        if (CheckDerivedToBaseConversion(FromPointeeType, ToPointeeType,
+                                         From->getExprLoc(),
+                                         From->getSourceRange()))
+          return true;
+        
+        // The conversion was successful.
+        Kind = CastExpr::CK_DerivedToBase;
       }
     }
   if (const ObjCObjectPointerType *FromPtrType =





More information about the cfe-commits mailing list