From 668d3625030b37a340af05da9c8da0d79179698c Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 9 Oct 2011 19:10:41 +0000 Subject: Only allow taking the address of an expression of type 'overloaded function type' when that expression is actually an overloaded function reference (and not the address of an overloaded function reference). Fixes PR11066. llvm-svn: 141514 --- clang/lib/Sema/SemaExpr.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index de35ec85252..ee985f4ba73 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7348,8 +7348,15 @@ static QualType CheckAddressOfOperand(Sema &S, Expr *OrigOp, SourceLocation OpLoc) { if (OrigOp->isTypeDependent()) return S.Context.DependentTy; - if (OrigOp->getType() == S.Context.OverloadTy) + if (OrigOp->getType() == S.Context.OverloadTy) { + if (!isa(OrigOp->IgnoreParens())) { + S.Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof) + << OrigOp->getSourceRange(); + return QualType(); + } + return S.Context.OverloadTy; + } if (OrigOp->getType() == S.Context.UnknownAnyTy) return S.Context.UnknownAnyTy; if (OrigOp->getType() == S.Context.BoundMemberTy) { -- cgit v1.2.3