Don't crash on calling static member overloaded operator, PR14120

Patch from Brian Brooks!

llvm-svn: 167604
This commit is contained in:
Nico Weber 2012-11-09 06:06:14 +00:00
parent 5ad5a9511c
commit 1fefe417f0
2 changed files with 15 additions and 0 deletions

View File

@ -10997,6 +10997,11 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
// that calls this method, using Object for the implicit object
// parameter and passing along the remaining arguments.
CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
// An error diagnostic has already been printed when parsing the declaration.
if (Method->isStatic())
return ExprError();
const FunctionProtoType *Proto =
Method->getType()->getAs<FunctionProtoType>();

View File

@ -48,3 +48,13 @@ struct PR10839 {
operator int; // expected-error{{'operator int' cannot be the name of a variable or data member}}
int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
};
namespace PR14120 {
struct A {
static void operator()(int& i) { ++i; } // expected-error{{overloaded 'operator()' cannot be a static member function}}
};
void f() {
int i = 0;
A()(i);
}
}