[cfe-commits] r152725 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp

Douglas Gregor dgregor at apple.com
Wed Mar 14 09:55:17 PDT 2012


Author: dgregor
Date: Wed Mar 14 11:55:17 2012
New Revision: 152725

URL: http://llvm.org/viewvc/llvm-project?rev=152725&view=rev
Log:
Minor cleanup in attribute-related diagnostics, from Alexander Kornienko!

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=152725&r1=152724&r2=152725&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Mar 14 11:55:17 2012
@@ -1569,16 +1569,15 @@
 def warn_attribute_wrong_decl_type : Warning<
   "%0 attribute only applies to %select{functions|unions|"
   "variables and functions|functions and methods|parameters|"
-  "parameters and methods|functions, methods and blocks|"
-  "classes and virtual methods|functions, methods, and parameters|"
-  "classes|virtual methods|class members|variables|methods|"
-  "variables, functions and labels|fields and global variables}1">;
+  "functions, methods and blocks|functions, methods, and parameters|"
+  "classes|variables|methods|variables, functions and labels|"
+  "fields and global variables|structs}1">;
 def err_attribute_wrong_decl_type : Error<
   "%0 attribute only applies to %select{functions|unions|"
   "variables and functions|functions and methods|parameters|"
-  "parameters and methods|functions, methods and blocks|"
-  "classes and virtual methods|functions, methods, and parameters|"
-  "classes|virtual methods|class members|variables|methods|structs}1">;
+  "functions, methods and blocks|functions, methods, and parameters|"
+  "classes|variables|methods|variables, functions and labels|"
+  "fields and global variables|structs}1">;
 def warn_function_attribute_wrong_type : Warning<
   "'%0' only applies to function types; type here is %1">;
 def warn_pointer_attribute_wrong_type : Warning<
@@ -3032,7 +3031,7 @@
   "size of anonymous bit-field (%0 bits) exceeds size of its type (%1 bits)">;
 def err_incorrect_number_of_vector_initializers : Error<
   "number of elements must be either one or match the size of the vector">;
-  
+
 // Used by C++ which allows bit-fields that are wider than the type.
 def warn_bitfield_width_exceeds_type_size: Warning<
   "size of bit-field %0 (%1 bits) exceeds the size of its type; value will be "
@@ -5096,7 +5095,7 @@
   "default label in switch which covers all enumeration values">,
   InGroup<CoveredSwitchDefault>, DefaultIgnore;
 def warn_not_in_enum : Warning<"case value not in enumerated type %0">,
-  InGroup<Switch>; 
+  InGroup<Switch>;
 def err_typecheck_statement_requires_scalar : Error<
   "statement requires expression of scalar type (%0 invalid)">;
 def err_typecheck_statement_requires_integer : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=152725&r1=152724&r2=152725&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Mar 14 11:55:17 2012
@@ -35,17 +35,14 @@
   ExpectedVariableOrFunction,
   ExpectedFunctionOrMethod,
   ExpectedParameter,
-  ExpectedParameterOrMethod,
   ExpectedFunctionMethodOrBlock,
-  ExpectedClassOrVirtualMethod,
   ExpectedFunctionMethodOrParameter,
   ExpectedClass,
-  ExpectedVirtualMethod,
-  ExpectedClassMember,
   ExpectedVariable,
   ExpectedMethod,
   ExpectedVariableFunctionOrLabel,
-  ExpectedFieldOrGlobalVar
+  ExpectedFieldOrGlobalVar,
+  ExpectedStruct
 };
 
 //===----------------------------------------------------------------------===//
@@ -787,7 +784,7 @@
   }
   else if (const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) {
     if (!PD->getType()->getAs<ObjCObjectPointerType>()) {
-      S.Diag(Attr.getLoc(), diag::warn_iboutlet_object_type) 
+      S.Diag(Attr.getLoc(), diag::warn_iboutlet_object_type)
         << Attr.getName() << PD->getType() << 1;
       return false;
     }
@@ -796,7 +793,7 @@
     S.Diag(Attr.getLoc(), diag::warn_attribute_iboutlet) << Attr.getName();
     return false;
   }
-  
+
   return true;
 }
 
@@ -3329,7 +3326,7 @@
 
   if (!isa<ObjCMethodDecl>(method)) {
     S.Diag(method->getLocStart(), diag::err_attribute_wrong_decl_type)
-      << SourceRange(loc, loc) << attr.getName() << 13 /* methods */;
+      << SourceRange(loc, loc) << attr.getName() << ExpectedMethod;
     return;
   }
 
@@ -3354,7 +3351,7 @@
 static void handleCFTransferAttr(Sema &S, Decl *D, const AttributeList &A) {
   if (!isa<FunctionDecl>(D)) {
     S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
-      << A.getRange() << A.getName() << 0 /*function*/;
+      << A.getRange() << A.getName() << ExpectedFunction;
     return;
   }
 
@@ -3390,7 +3387,7 @@
   RecordDecl *RD = dyn_cast<RecordDecl>(D);
   if (!RD || RD->isUnion()) {
     S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
-      << Attr.getRange() << Attr.getName() << 14 /*struct */;
+      << Attr.getRange() << Attr.getName() << ExpectedStruct;
   }
 
   IdentifierInfo *ParmName = Attr.getParameterName();
@@ -3420,14 +3417,14 @@
   if (hasDeclarator(D)) return;
 
   S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
-    << Attr.getRange() << Attr.getName() << 12 /* variable */;
+    << Attr.getRange() << Attr.getName() << ExpectedVariable;
 }
 
 static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D,
                                           const AttributeList &Attr) {
   if (!isa<VarDecl>(D) && !isa<FieldDecl>(D)) {
     S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
-      << Attr.getRange() << Attr.getName() << 12 /* variable */;
+      << Attr.getRange() << Attr.getName() << ExpectedVariable;
     return;
   }
 
@@ -3507,7 +3504,7 @@
 
     bool IsCurly = StrRef.size() > 1 && StrRef.front() == '{' &&
                    StrRef.back() == '}';
-    
+
     // Validate GUID length.
     if (IsCurly && StrRef.size() != 38) {
       S.Diag(Attr.getLoc(), diag::err_attribute_uuid_malformed_guid);
@@ -3518,7 +3515,7 @@
       return;
     }
 
-    // GUID format is "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" or 
+    // GUID format is "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" or
     // "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
     StringRef::iterator I = StrRef.begin();
     if (IsCurly) // Skip the optional '{'





More information about the cfe-commits mailing list