VDecl->getName(), DefaultArg->getSourceRange());
}
- // FIXME: when Clang has support for member functions, "this"
- // will also need to be diagnosed.
+ // C++ [dcl.fct.default]p8:
+ // The keyword this shall not be used in a default argument of a
+ // member function.
+ // Note: this requirement is already diagnosed by
+ // Sema::ActOnCXXThis, because the use of "this" inside a default
+ // argument doesn't occur inside the body of a non-static member
+ // function.
return false;
}
void (*f2)(int = 17) // {expected-error {{default arguments can only be specified}}}
= (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
}
+
+class X {
+ void f(X* x = this); // expected-error{{invalid use of 'this' outside of a nonstatic member function}}
+};