diff options
author | Steve Naroff <snaroff@apple.com> | 2009-04-13 17:58:46 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-04-13 17:58:46 +0000 |
commit | 87454161a6377b573d4fc3ff45e7b3ec193e860c (patch) | |
tree | 20c829ecc4bb04d728cd5c5e265cb4c2ea081125 | |
parent | 8533bd5a32a12c51341e82d2aef083acbac7c04c (diff) |
Change diagnostic as a result of researching <rdar://problem/6779809> missing interface name in "error: cannot declare variable inside a class, protocol or category ''.
Since ObjC 2.0 class "extensions" have a null name, the diagnostic above is actually "correct". Nevertheless, it is confusing. Decided to remove the name entirely (from my perspective, it didn't add any value). Also simplified the text of the diagnostic a bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68967 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 3 | ||||
-rw-r--r-- | test/SemaObjC/interface-tu-variable.m | 13 |
3 files changed, 11 insertions, 7 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 25aa58fffb..56a9fa9ac3 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -172,7 +172,7 @@ def note_declared_at : Note<"declared at">; def err_setter_type_void : Error<"type of setter must be void">; def err_duplicate_method_decl : Error<"duplicate declaration of method %0">; def err_objc_var_decl_inclass : - Error<"cannot declare variable inside a class, protocol or category %0">; + Error<"cannot declare variable inside @interface or @protocol">; def error_missing_method_context : Error< "missing context for method declaration">; def err_objc_property_attr_mutually_exclusive : Error< diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 49433b5b7b..cf782caf5c 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1358,8 +1358,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl, if (VarDecl *VDecl = dyn_cast<VarDecl>(*I)) { if (VDecl->getStorageClass() != VarDecl::Extern && VDecl->getStorageClass() != VarDecl::PrivateExtern) - Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass) - << cast<NamedDecl>(ClassDecl)->getDeclName(); + Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass); } } } diff --git a/test/SemaObjC/interface-tu-variable.m b/test/SemaObjC/interface-tu-variable.m index 667c632aa5..9bf816ab69 100644 --- a/test/SemaObjC/interface-tu-variable.m +++ b/test/SemaObjC/interface-tu-variable.m @@ -1,19 +1,24 @@ // RUN: clang-cc -fsyntax-only -verify %s @interface XX -int x; // expected-error {{cannot declare variable inside a class, protocol or category}} -int one=1; // expected-error {{cannot declare variable inside a class, protocol or category}} +int x; // expected-error {{cannot declare variable inside @interface or @protocol}} +int one=1; // expected-error {{cannot declare variable inside @interface or @protocol}} @end @protocol PPP -int ddd; // expected-error {{cannot declare variable inside a class, protocol or category}} +int ddd; // expected-error {{cannot declare variable inside @interface or @protocol}} @end @interface XX(CAT) - char * III; // expected-error {{cannot declare variable inside a class, protocol or category}} + char * III; // expected-error {{cannot declare variable inside @interface or @protocol}} extern int OK; @end +@interface XX() + char * III2; // expected-error {{cannot declare variable inside @interface or @protocol}} + extern int OK2; +@end + int main( int argc, const char *argv[] ) { return x+one; |