1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

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

Source commit: 85cc13e319936e7644a5adde71d09623113e9176
This commit is contained in:
Martin Prikryl
2025-03-14 07:02:11 +00:00
parent fcb82a2581
commit 8073dbef30
4 changed files with 9 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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; }

View File

@@ -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