[cfe-commits] r45834 - in /cfe/trunk: Parse/ParseObjc.cpp include/clang/Basic/DiagnosticKinds.def test/Parser/objc-missing-impl.m
Fariborz Jahanian
fjahanian at apple.com
Thu Jan 10 09:58:08 PST 2008
Author: fjahanian
Date: Thu Jan 10 11:58:07 2008
New Revision: 45834
URL: http://llvm.org/viewvc/llvm-project?rev=45834&view=rev
Log:
Warn (as gcc does) when @end does not close anything.
Added:
cfe/trunk/test/Parser/objc-missing-impl.m
Modified:
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=45834&r1=45833&r2=45834&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Thu Jan 10 11:58:07 2008
@@ -991,13 +991,10 @@
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;
}
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=45834&r1=45833&r2=45834&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Thu Jan 10 11:58:07 2008
@@ -478,6 +478,8 @@
"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
Added: cfe/trunk/test/Parser/objc-missing-impl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-missing-impl.m?rev=45834&view=auto
==============================================================================
--- cfe/trunk/test/Parser/objc-missing-impl.m (added)
+++ cfe/trunk/test/Parser/objc-missing-impl.m Thu Jan 10 11:58:07 2008
@@ -0,0 +1,2 @@
+// RUN: clang -fsyntax-only -verify %s
+ at end // expected-warning {{â@endâ must appear in an @implementation context}}
More information about the cfe-commits
mailing list