Don't crash on calling static member overloaded operator, PR14120
Patch from Brian Brooks! llvm-svn: 167604
This commit is contained in:
parent
5ad5a9511c
commit
1fefe417f0
|
@ -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>();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue