diff options
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
| -rw-r--r-- | lib/Sema/SemaOverload.cpp | 31 | 
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 5cc13f391d11..36f24fd9c463 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -48,7 +48,7 @@ static bool functionHasPassObjectSizeParams(const FunctionDecl *FD) {  /// A convenience routine for creating a decayed reference to a function.  static ExprResult  CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, -                      bool HadMultipleCandidates, +                      const Expr *Base, bool HadMultipleCandidates,                        SourceLocation Loc = SourceLocation(),                        const DeclarationNameLoc &LocInfo = DeclarationNameLoc()){    if (S.DiagnoseUseOfDecl(FoundDecl, Loc)) @@ -68,7 +68,7 @@ CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl,    if (HadMultipleCandidates)      DRE->setHadMultipleCandidates(true); -  S.MarkDeclRefReferenced(DRE); +  S.MarkDeclRefReferenced(DRE, Base);    return S.ImpCastExprToType(DRE, S.Context.getPointerType(DRE->getType()),                               CK_FunctionToPointerDecay);  } @@ -9830,6 +9830,15 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,        return;      } +    // We found a specific requirement that disabled the enable_if. +    if (PDiag && PDiag->second.getDiagID() == +        diag::err_typename_nested_not_found_requirement) { +      S.Diag(Templated->getLocation(), +             diag::note_ovl_candidate_disabled_by_requirement) +        << PDiag->second.getStringArg(0) << TemplateArgString; +      return; +    } +      // Format the SFINAE diagnostic into the argument string.      // FIXME: Add a general mechanism to include a PartialDiagnostic *'s      //        formatted message in another diagnostic. @@ -11937,6 +11946,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,      FunctionDecl *FnDecl = Best->Function;      if (FnDecl) { +      Expr *Base = nullptr;        // We matched an overloaded operator. Build a call to that        // operator. @@ -11949,7 +11959,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,                                                Best->FoundDecl, Method);          if (InputRes.isInvalid())            return ExprError(); -        Input = InputRes.get(); +        Base = Input = InputRes.get();        } else {          // Convert the arguments.          ExprResult InputInit @@ -11965,7 +11975,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,        // Build the actual expression node.        ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, Best->FoundDecl, -                                                HadMultipleCandidates, OpLoc); +                                                Base, HadMultipleCandidates, +                                                OpLoc);        if (FnExpr.isInvalid())          return ExprError(); @@ -12150,6 +12161,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,        FunctionDecl *FnDecl = Best->Function;        if (FnDecl) { +        Expr *Base = nullptr;          // We matched an overloaded operator. Build a call to that          // operator. @@ -12171,7 +12183,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,                                                  Best->FoundDecl, Method);            if (Arg0.isInvalid())              return ExprError(); -          Args[0] = Arg0.getAs<Expr>(); +          Base = Args[0] = Arg0.getAs<Expr>();            Args[1] = RHS = Arg1.getAs<Expr>();          } else {            // Convert the arguments. @@ -12195,7 +12207,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,          // Build the actual expression node.          ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, -                                                  Best->FoundDecl, +                                                  Best->FoundDecl, Base,                                                    HadMultipleCandidates, OpLoc);          if (FnExpr.isInvalid())            return ExprError(); @@ -12417,6 +12429,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,          OpLocInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));          ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl,                                                    Best->FoundDecl, +                                                  Base,                                                    HadMultipleCandidates,                                                    OpLocInfo.getLoc(),                                                    OpLocInfo.getInfo()); @@ -12975,7 +12988,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,                 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);    OpLocInfo.setCXXOperatorNameRange(SourceRange(LParenLoc, RParenLoc));    ExprResult NewFn = CreateFunctionRefExpr(*this, Method, Best->FoundDecl, -                                           HadMultipleCandidates, +                                           Obj, HadMultipleCandidates,                                             OpLocInfo.getLoc(),                                             OpLocInfo.getInfo());    if (NewFn.isInvalid()) @@ -13166,7 +13179,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,    // Build the operator call.    ExprResult FnExpr = CreateFunctionRefExpr(*this, Method, Best->FoundDecl, -                                            HadMultipleCandidates, OpLoc); +                                            Base, HadMultipleCandidates, OpLoc);    if (FnExpr.isInvalid())      return ExprError(); @@ -13225,7 +13238,7 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R,    FunctionDecl *FD = Best->Function;    ExprResult Fn = CreateFunctionRefExpr(*this, FD, Best->FoundDecl, -                                        HadMultipleCandidates, +                                        nullptr, HadMultipleCandidates,                                          SuffixInfo.getLoc(),                                          SuffixInfo.getInfo());    if (Fn.isInvalid())  | 
