Преглед изворни кода

Clang incorrectly warns about some variables being unintialized, while the classic compiler warns that the value is never used

Source commit: 85cc13e319936e7644a5adde71d09623113e9176
Martin Prikryl пре 7 месеци
родитељ
комит
8073dbef30
4 измењених фајлова са 9 додато и 3 уклоњено
  1. 1 1
      source/core/Common.cpp
  2. 1 1
      source/core/FtpFileSystem.cpp
  3. 6 0
      source/core/Global.h
  4. 1 1
      source/core/NamedObjs.cpp

+ 1 - 1
source/core/Common.cpp

@@ -3920,7 +3920,7 @@ UnicodeString __fastcall RtfEscapeParam(UnicodeString Param, bool PowerShellEsca
     else
     {
       int P2 = PosEx(RtfHyperlinkFieldPrefix, Param, Index);
-      int P3 = 0; // shut up
+      int P3 CLANG_INITIALIZE(0);
       if ((P2 > 0) && (P2 < P1) && ((P3 = PosEx(RtfHyperlinkFieldSuffix, Param, P2)) > 0))
       {
         // skip HYPERLINK

+ 1 - 1
source/core/FtpFileSystem.cpp

@@ -4043,7 +4043,7 @@ UnicodeString __fastcall FormatValidityTime(const TFtpsCertificateData::TValidit
 bool __fastcall VerifyNameMask(UnicodeString Name, UnicodeString Mask)
 {
   bool Result = true;
-  int Pos = 0; // shut up
+  int Pos CLANG_INITIALIZE(0);
   while (Result && (Pos = Mask.Pos(L"*")) > 0)
   {
     // Pos will typically be 1 here, so not actual comparison is done

+ 6 - 0
source/core/Global.h

@@ -34,6 +34,12 @@ private:
   TCriticalSection * FCriticalSection;
 };
 //---------------------------------------------------------------------------
+#ifdef __clang__
+#define CLANG_INITIALIZE(V) = (V)
+#else
+#define CLANG_INITIALIZE(V)
+#endif
+//---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 #include <assert.h>
 #define ACCESS_VIOLATION_TEST { (*((int*)NULL)) = 0; }

+ 1 - 1
source/core/NamedObjs.cpp

@@ -52,7 +52,7 @@ void __fastcall TNamedObject::MakeUniqueIn(TNamedObjectList * List)
   if (List && (List->IndexOf(this) == -1))
     while (List->FindByName(Name))
     {
-      Integer N = 0, P = 0; // shut up
+      Integer N = 0, P CLANG_INITIALIZE(0);
       // If name already contains number parenthesis remove it (and remember it)
       if ((Name[Name.Length()] == L')') && ((P = Name.LastDelimiter(L'(')) > 0))
         try