[cfe-commits] r68967 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjC/interface-tu-variable.m

Steve Naroff snaroff at apple.com
Mon Apr 13 10:58:46 PDT 2009


Author: snaroff
Date: Mon Apr 13 12:58:46 2009
New Revision: 68967

URL: http://llvm.org/viewvc/llvm-project?rev=68967&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/interface-tu-variable.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=68967&r1=68966&r2=68967&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 13 12:58:46 2009
@@ -172,7 +172,7 @@
 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<

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=68967&r1=68966&r2=68967&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Apr 13 12:58:46 2009
@@ -1358,8 +1358,7 @@
         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);
         }
     }
   }

Modified: cfe/trunk/test/SemaObjC/interface-tu-variable.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/interface-tu-variable.m?rev=68967&r1=68966&r2=68967&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/interface-tu-variable.m (original)
+++ cfe/trunk/test/SemaObjC/interface-tu-variable.m Mon Apr 13 12:58:46 2009
@@ -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
 
+ at interface XX()
+  char * III2; // expected-error {{cannot declare variable inside @interface or @protocol}}
+  extern int OK2;
+ at end
+
 
 int main( int argc, const char *argv[] ) {
     return x+one;





More information about the cfe-commits mailing list