]> granicus.if.org Git - clang/commitdiff
Remove default arguments from TryImplicitConversion and fix a bug found in the process.
authorAnders Carlsson <andersca@mac.com>
Thu, 27 Aug 2009 17:24:15 +0000 (17:24 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 27 Aug 2009 17:24:15 +0000 (17:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80258 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
lib/Sema/SemaCXXCast.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp

index 2ed90d016469261c85dd6c7968b8308a16cc253e..b19368816b58849bb1839d187f81f074cc631bc2 100644 (file)
@@ -725,9 +725,9 @@ public:
                   OverloadedFunctionDecl::function_iterator &MatchedDecl);
   ImplicitConversionSequence 
   TryImplicitConversion(Expr* From, QualType ToType,
-                        bool SuppressUserConversions = false,
-                        bool AllowExplicit = false,
-                        bool ForceRValue = false);
+                        bool SuppressUserConversions,
+                        bool AllowExplicit,
+                        bool ForceRValue);
   bool IsStandardConversion(Expr *From, QualType ToType, 
                             StandardConversionSequence& SCS);
   bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
index 17fe940136f494e6310619f3df20230fc254708c..3643b8808eb79a358de55755a06690f1226296c3 100644 (file)
@@ -788,8 +788,12 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
   // reimplement more of this.
   // FIXME: This does not actually perform the conversion, and thus does not
   // check for ambiguity or access.
-  ImplicitConversionSequence ICS = Self.TryImplicitConversion(
-    SrcExpr, DestType);
+  ImplicitConversionSequence ICS = 
+    Self.TryImplicitConversion(SrcExpr, DestType,
+                               /*SuppressUserConversions=*/false,
+                               /*AllowExplicit=*/false,
+                               /*ForceRValue=*/false);
+  
   if (ICS.ConversionKind  == ImplicitConversionSequence::UserDefinedConversion)
     if (CXXConversionDecl *CV = 
           dyn_cast<CXXConversionDecl>(ICS.UserDefined.ConversionFunction))
index c5eda94b6a66e89bbd671ec16d57e5be0d4622fc..eb4299f79cf3cb2394b05c29fa97e762bce038d4 100644 (file)
@@ -3144,7 +3144,10 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
     //   the argument expression. Any difference in top-level
     //   cv-qualification is subsumed by the initialization itself
     //   and does not constitute a conversion.
-    *ICS = TryImplicitConversion(Init, T1, SuppressUserConversions);
+    *ICS = TryImplicitConversion(Init, T1, SuppressUserConversions,
+                                 /*AllowExplicit=*/false,
+                                 /*ForceRValue=*/false);
+    
     // Of course, that's still a reference binding.
     if (ICS->ConversionKind == ImplicitConversionSequence::StandardConversion) {
       ICS->Standard.ReferenceBinding = true;
index 870041dc87e8d99d541643f43dd6dadb348040f2..98b3d29e531631fea20d50a95f89db3929dbcdcf 100644 (file)
@@ -884,11 +884,16 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
   ImplicitConversionSequence ICS;
   ICS.ConversionKind = ImplicitConversionSequence::BadConversion;
   if (Elidable && getLangOptions().CPlusPlus0x) {
-    ICS = TryImplicitConversion(From, ToType, /*SuppressUserConversions*/false,
-                                AllowExplicit, /*ForceRValue*/true);
+    ICS = TryImplicitConversion(From, ToType, 
+                                /*SuppressUserConversions=*/false,
+                                AllowExplicit, 
+                                /*ForceRValue=*/true);
   }
   if (ICS.ConversionKind == ImplicitConversionSequence::BadConversion) {
-    ICS = TryImplicitConversion(From, ToType, false, AllowExplicit);
+    ICS = TryImplicitConversion(From, ToType, 
+                                /*SuppressUserConversions=*/false,
+                                AllowExplicit,
+                                /*ForceRValue=*/false);
   }
   return PerformImplicitConversion(From, ToType, ICS, Flavor);
 }
@@ -1244,7 +1249,10 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
 
     // Now try the implicit conversion.
     // FIXME: This doesn't detect ambiguities.
-    ICS = Self.TryImplicitConversion(From, TTy);
+    ICS = Self.TryImplicitConversion(From, TTy,
+                                     /*SuppressUserConversions=*/false,
+                                     /*AllowExplicit=*/false,
+                                     /*ForceRValue=*/false);
   }
   return false;
 }
@@ -1627,15 +1635,30 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
     }
   }
 
-  ImplicitConversionSequence E1ToC1 = TryImplicitConversion(E1, Composite1);
-  ImplicitConversionSequence E2ToC1 = TryImplicitConversion(E2, Composite1);
+  ImplicitConversionSequence E1ToC1 = 
+    TryImplicitConversion(E1, Composite1,
+                          /*SuppressUserConversions=*/false,
+                          /*AllowExplicit=*/false,
+                          /*ForceRValue=*/false);
+  ImplicitConversionSequence E2ToC1 = 
+    TryImplicitConversion(E2, Composite1,
+                          /*SuppressUserConversions=*/false,
+                          /*AllowExplicit=*/false,
+                          /*ForceRValue=*/false);
+  
   ImplicitConversionSequence E1ToC2, E2ToC2;
   E1ToC2.ConversionKind = ImplicitConversionSequence::BadConversion;
   E2ToC2.ConversionKind = ImplicitConversionSequence::BadConversion;
   if (Context.getCanonicalType(Composite1) !=
       Context.getCanonicalType(Composite2)) {
-    E1ToC2 = TryImplicitConversion(E1, Composite2);
-    E2ToC2 = TryImplicitConversion(E2, Composite2);
+    E1ToC2 = TryImplicitConversion(E1, Composite2,
+                                   /*SuppressUserConversions=*/false,
+                                   /*AllowExplicit=*/false,
+                                   /*ForceRValue=*/false);
+    E2ToC2 = TryImplicitConversion(E2, Composite2,
+                                   /*SuppressUserConversions=*/false,
+                                   /*AllowExplicit=*/false,
+                                   /*ForceRValue=*/false);
   }
 
   bool ToC1Viable = E1ToC1.ConversionKind !=
index 52010ab514540d13be2bd73fbd9a60cd2a4436c7..b1364a9faab46eed45e4852b43de73a1ea585152 100644 (file)
@@ -1929,7 +1929,9 @@ Sema::TryCopyInitialization(Expr *From, QualType ToType,
                        /*AllowExplicit=*/false, ForceRValue);
     return ICS;
   } else {
-    return TryImplicitConversion(From, ToType, SuppressUserConversions,
+    return TryImplicitConversion(From, ToType, 
+                                 SuppressUserConversions,
+                                 /*AllowExplicit=*/false,
                                  ForceRValue);
   }
 }
@@ -2064,7 +2066,11 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
 /// TryContextuallyConvertToBool - Attempt to contextually convert the
 /// expression From to bool (C++0x [conv]p3).
 ImplicitConversionSequence Sema::TryContextuallyConvertToBool(Expr *From) {
-  return TryImplicitConversion(From, Context.BoolTy, false, true);
+  return TryImplicitConversion(From, Context.BoolTy, 
+                               // FIXME: Are these flags correct?
+                               /*SuppressUserConversions=*/false,
+                               /*AllowExplicit=*/true, 
+                               /*ForceRValue=*/false);
 }
 
 /// PerformContextuallyConvertToBool - Perform a contextual conversion