From: Douglas Gregor Date: Tue, 13 Apr 2010 15:50:39 +0000 (+0000) Subject: When returning the result of a call to an object of class type, do not X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa0be17ee35e3218b722d90b74789f9e7c602bda;p=clang When returning the result of a call to an object of class type, do not return a NULL expression; return either an error or a proper expression. Fixes PR6078. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101133 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index cfc8068b96..40d48e3cc6 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -6293,7 +6293,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, return ActOnCallExpr(S, ExprArg(*this, CE), LParenLoc, MultiExprArg(*this, (ExprTy**)Args, NumArgs), - CommaLocs, RParenLoc).release(); + CommaLocs, RParenLoc).result(); } CheckMemberOperatorAccess(LParenLoc, Object, 0, Best->FoundDecl); @@ -6397,7 +6397,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, if (CheckFunctionCall(Method, TheCall.get())) return true; - return MaybeBindToTemporary(TheCall.release()).release(); + return MaybeBindToTemporary(TheCall.release()).result(); } /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator-> diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index c286028c29..f3a5fba8e6 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -406,3 +406,18 @@ namespace PR6483 { f1(x1); // expected-error{{no matching function for call}} } } + +namespace PR6078 { + struct A { // expected-note{{candidate is the implicit copy constructor}} + A(short); // expected-note{{candidate constructor}} + A(long); // expected-note{{candidate constructor}} + }; + struct S { + typedef void ft(A); + operator ft*(); + }; + + void f() { + S()(0); // expected-error{{conversion from 'int' to 'PR6078::A' is ambiguous}} + } +}