diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaObjC/interface-tu-variable.m | 13 |
3 files changed, 11 insertions, 7 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 25aa58fffbb..56a9fa9ac3e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/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/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 49433b5b7b0..cf782caf5c0 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/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/clang/test/SemaObjC/interface-tu-variable.m b/clang/test/SemaObjC/interface-tu-variable.m index 667c632aa5c..9bf816ab69f 100644 --- a/clang/test/SemaObjC/interface-tu-variable.m +++ b/clang/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; |