]> granicus.if.org Git - clang/commitdiff
Fix C++0x narrowing conversion errors in Clang.
authorJeffrey Yasskin <jyasskin@google.com>
Sat, 13 Aug 2011 05:47:04 +0000 (05:47 +0000)
committerJeffrey Yasskin <jyasskin@google.com>
Sat, 13 Aug 2011 05:47:04 +0000 (05:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137552 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/DiagnosticIDs.cpp

index 66b16a9ba1c9efa86063b940e76be0cd47910fca..907e826a33c71b213a83a5e26d486d7088fdce9f 100644 (file)
@@ -166,7 +166,8 @@ static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
 #endif
 
   // Search the diagnostic table with a binary search.
-  StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0 };
+  StaticDiagInfoRec Find = { static_cast<unsigned short>(DiagID),
+                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
   const StaticDiagInfoRec *Found =
     std::lower_bound(StaticDiagInfo, StaticDiagInfo + StaticDiagInfoSize, Find);
@@ -269,7 +270,10 @@ unsigned DiagnosticIDs::getIdFromName(StringRef Name) {
   
   if (Name.empty()) { return diag::DIAG_UPPER_LIMIT; }
   
-  StaticDiagNameIndexRec Find = { Name.data(), 0, Name.size() };
+  assert(Name.size() == static_cast<uint8_t>(Name.size()) &&
+         "Name is too long");
+  StaticDiagNameIndexRec Find = { Name.data(), 0,
+                                  static_cast<uint8_t>(Name.size()) };
   
   const StaticDiagNameIndexRec *Found =
     std::lower_bound( StaticDiagNameIndex, StaticDiagNameIndexEnd, Find);