// We should have an opening brace now.
if (Tok.isNot(tok::l_brace)) {
- Diag(Tok, diag::err_expected_fn_body);
+ Diag(Tok, diag::err_expected_method_body);
// Skip over garbage, until we get to '{'. Don't eat the '{'.
SkipUntil(tok::l_brace, true, true);
ObjCDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind,
bool isVariadic) {
+
+ // Make sure we can establish a context for the method.
+ if (!ClassDecl) {
+ Diag(MethodLoc, diag::error_missing_method_context);
+ return 0;
+ }
llvm::SmallVector<ParmVarDecl*, 16> Params;
for (unsigned i = 0; i < Sel.getNumArgs(); i++) {
"function definition declared 'typedef'")
DIAG(err_expected_fn_body, ERROR,
"expected function body after function declarator")
+DIAG(err_expected_method_body, ERROR,
+ "expected method body")
DIAG(err_expected_after_declarator, ERROR,
"expected '=', ',', ';', 'asm', or '__attribute__' after declarator")
DIAG(err_expected_statement, ERROR,
"Only one element declaration is allowed")
DIAG(warn_expected_implementation, WARNING,
"@end must appear in an @implementation context")
+DIAG(error_missing_method_context, ERROR,
+ "missing context for method declaration")
DIAG(error_bad_receiver_type, ERROR,
"bad receiver type '%0'")
--- /dev/null
+// RUN: clang %s -verify -fsyntax-only
+- (void)compilerTestAgainst; // expected-error {{missing context for method declaration}}
+
+void xx(); // expected-error {{expected method body}}