aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Parse/ParseObjc.cpp9
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--test/Parser/objc-missing-impl.m2
3 files changed, 7 insertions, 6 deletions
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index 989f1dce17..34694ef5c5 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -991,13 +991,10 @@ Parser::DeclTy *Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) {
assert(Tok.isObjCAtKeyword(tok::objc_end) &&
"ParseObjCAtEndDeclaration(): Expected @end");
ConsumeToken(); // the "end" identifier
- if (ObjCImpDecl) {
- // Checking is not necessary except that a parse error might have caused
- // @implementation not to have been parsed to completion and ObjCImpDecl
- // could be 0.
+ if (ObjCImpDecl)
Actions.ActOnAtEnd(atLoc, ObjCImpDecl);
- }
-
+ else
+ Diag(atLoc, diag::warn_expected_implementation); // missing @implementation
return ObjCImpDecl;
}
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 289f770ec6..f041a3a47b 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -478,6 +478,8 @@ DIAG(err_selector_element_type, ERROR,
"selector element is not of valid object type (its type is '%0')")
DIAG(err_toomany_element_decls, ERROR,
"Only one element declaration is allowed")
+DIAG(warn_expected_implementation, WARNING,
+ "‘@end’ must appear in an @implementation context")
//===----------------------------------------------------------------------===//
// Semantic Analysis
diff --git a/test/Parser/objc-missing-impl.m b/test/Parser/objc-missing-impl.m
new file mode 100644
index 0000000000..062130d358
--- /dev/null
+++ b/test/Parser/objc-missing-impl.m
@@ -0,0 +1,2 @@
+// RUN: clang -fsyntax-only -verify %s
+@end // expected-warning {{‘@end’ must appear in an @implementation context}}