Fix a minor edge case in C89 mode related to the definition of a

"function designator".

(This causes a minor glitch in the 
diagnostics for C++ member pointers, but we weren't printing the 
right diagnostic there anyway.)

llvm-svn: 70307
This commit is contained in:
Eli Friedman 2009-04-28 17:59:09 +00:00
parent 9f1d66419d
commit 4058a842e6
3 changed files with 4 additions and 2 deletions

View File

@ -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<FunctionDecl>(dcl)) {
if (!op->getType()->isFunctionType()) {
// FIXME: emit more specific diag...
Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
<< op->getSourceRange();

View File

@ -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)(); }

View File

@ -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;