Author: dgregor
Date: Sun Oct 9 14:10:41 2011
New Revision: 141514
URL: http://llvm.org/viewvc/llvm-project?rev=141514&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/address-of.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=141514&r1=141513&r2=141514&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Oct 9 14:10:41 2011
@@ -7348,8 +7348,15 @@
SourceLocation OpLoc) {
if (OrigOp->isTypeDependent())
return S.Context.DependentTy;
- if (OrigOp->getType() == S.Context.OverloadTy)
+ if (OrigOp->getType() == S.Context.OverloadTy) {
+ if (!isa<OverloadExpr>(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) {
Modified: cfe/trunk/test/SemaCXX/address-of.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/address-of.cpp?rev=141514&r1=141513&r2=141514&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/address-of.cpp (original)
+++ cfe/trunk/test/SemaCXX/address-of.cpp Sun Oct 9 14:10:41 2011
@@ -33,3 +33,14 @@
// PR clang/3222
void xpto();
void (*xyz)(void) = &xpto;
+
+struct PR11066 {
+ static int foo(short);
+ static int foo(float);
+ void test();
+};
+
+void PR11066::test() {
+ int (PR11066::*ptr)(int) = & &PR11066::foo; // expected-error{{address
expression must be an lvalue or a function designator}}
+}
+
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits