diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 045fa180e65c..c4360a94a725 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4095,7 +4095,7 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) { if (lval != Expr::LV_Valid) { // C99 6.5.3.2p1 // The operand must be either an l-value or a function designator - if (!dcl || !isa(dcl)) { + if (!op->getType()->isFunctionType()) { // FIXME: emit more specific diag... Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof) << op->getSourceRange(); diff --git a/clang/test/Sema/c89.c b/clang/test/Sema/c89.c index 3b1c7766fe56..e7585c31926c 100644 --- a/clang/test/Sema/c89.c +++ b/clang/test/Sema/c89.c @@ -78,3 +78,5 @@ void test13b() { int b = 1[test13a().X]; /* expected-warning {{ISO C90 does not allow subscripting non-lvalue array}} */ } +/* Make sure we allow *test14 as a "function designator" */ +int test14() { return (&*test14)(); } diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp index 11993a1d4bd2..1a663f6e1cca 100644 --- a/clang/test/SemaCXX/member-pointer.cpp +++ b/clang/test/SemaCXX/member-pointer.cpp @@ -71,7 +71,7 @@ void g() { void (HasMembers::*pmf)() = &HasMembers::f; void (*pnf)() = &Fake::f; - &hm.f; // expected-error {{address expression must be an lvalue or a function designator}} + &hm.f; // FIXME: needs diagnostic expected-warning{{result unused}} void (HasMembers::*pmgv)() = &HasMembers::g; void (HasMembers::*pmgi)(int) = &HasMembers::g;