From ef9b1497908ab1684e04f244289f1ebe8d44274e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 9 Nov 2010 20:03:54 +0000 Subject: [PATCH] Revert the fix for PR8013. That bug concerned the well-formedness of code such as (&ovl)(a, b, c). GCC rejects the code, while EDG accepts it. On further study of the standard, I see no support for EDG's position: in particular, C++ [over.over] does not list this as a context where we can take the address of an overloaded function, C++ [over.call.func] does not reference the address-of operator at any point, and C++ [expr.call] claims that the function argument in a call is either a function lvalue or a pointer-to-function; (&ovl) is neither. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118620 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaCodeComplete.cpp | 4 ---- lib/Sema/SemaExpr.cpp | 10 ++++++---- test/CodeCompletion/call.cpp | 6 ++---- test/SemaCXX/overload-call.cpp | 8 -------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 27943d5d3f..73c19a755b 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -3306,10 +3306,6 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn, llvm::SmallVector Results; Expr *NakedFn = Fn->IgnoreParenCasts(); - if (UnaryOperator *UnOp = dyn_cast(NakedFn)) - if (UnOp->getOpcode() == UO_AddrOf) - NakedFn = UnOp->getSubExpr()->IgnoreParens(); - if (UnresolvedLookupExpr *ULE = dyn_cast(NakedFn)) AddOverloadedCallCandidates(ULE, Args, NumArgs, CandidateSet, /*PartialOverloading=*/ true); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f404c20b41..0d0f48cd74 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3781,15 +3781,17 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, // lookup and whether there were any explicitly-specified template arguments. Expr *NakedFn = Fn->IgnoreParens(); + if (isa(NakedFn)) { + UnresolvedLookupExpr *ULE = cast(NakedFn); + return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, Args, NumArgs, + RParenLoc); + } + NamedDecl *NDecl = 0; if (UnaryOperator *UnOp = dyn_cast(NakedFn)) if (UnOp->getOpcode() == UO_AddrOf) NakedFn = UnOp->getSubExpr()->IgnoreParens(); - if (UnresolvedLookupExpr *ULE = dyn_cast(NakedFn)) - return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, Args, NumArgs, - RParenLoc); - if (isa(NakedFn)) NDecl = cast(NakedFn)->getDecl(); diff --git a/test/CodeCompletion/call.cpp b/test/CodeCompletion/call.cpp index 65b1cf1f2b..f06470f4cb 100644 --- a/test/CodeCompletion/call.cpp +++ b/test/CodeCompletion/call.cpp @@ -17,14 +17,12 @@ void f(); void test() { f(Y(), 0, 0); - (&f)(Y(), 0, 0); - // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) // CHECK-CC1: f(N::Y y, <#int ZZ#>) // CHECK-CC1-NEXT: f(int i, <#int j#>, int k) // CHECK-CC1-NEXT: f(float x, <#float y#>) - // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CC2 %s // CHECK-CC2-NOT: f(N::Y y, int ZZ) // CHECK-CC2: f(int i, int j, <#int k#>) } - // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:20:16 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index 7aeb9522f1..81a88a3a9a 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -503,11 +503,3 @@ namespace rdar8499524 { g(W()); } } - -namespace PR8013 { - void f(int,int); - void f(int,int,int); - void g() { - (&f)(1,2,3); - } -} -- 2.40.0