Fixed various warnings from clang

This commit is contained in:
Daniel Gibson 2012-12-22 06:15:50 +01:00
parent 9280732913
commit ba126dde3a
17 changed files with 49 additions and 24 deletions

View file

@ -794,7 +794,8 @@ template< class type >
ID_INLINE type* idEntityPtr<type>::GetEntity() const
{
int entityNum = spawnId & ( ( 1 << GENTITYNUM_BITS ) - 1 );
if( ( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) ) )
// DG: removed extraneous parenthesis to shut up clang
if( gameLocal.spawnIds[ entityNum ] == ( spawnId >> GENTITYNUM_BITS ) )
{
return static_cast<type*>( gameLocal.entities[ entityNum ] );
}

View file

@ -1513,7 +1513,7 @@ void FullscreenFX_DoubleVision::HighQuality()
color.z = 0.0f;
}
if( !common->IsMultiplayer() && gameLocal.fast.time < player->inventory.powerupEndTime[ HELLTIME ] || gameLocal.fast.time < player->inventory.powerupEndTime[ INVULNERABILITY ] )
if( ( !common->IsMultiplayer() && gameLocal.fast.time < player->inventory.powerupEndTime[ HELLTIME ] ) || gameLocal.fast.time < player->inventory.powerupEndTime[ INVULNERABILITY ] )
{
color.y = 0.0f;
color.z = 0.0f;

View file

@ -952,7 +952,8 @@ void idAI::Event_CanBecomeSolid()
continue;
}
if( spawnClearMoveables && hit->IsType( idMoveable::Type ) || hit->IsType( idBarrel::Type ) || hit->IsType( idExplodingBarrel::Type ) )
// DG: add parenthesis to make precedence obvious and to appease compiler
if( ( spawnClearMoveables && hit->IsType( idMoveable::Type ) ) || hit->IsType( idBarrel::Type ) || hit->IsType( idExplodingBarrel::Type ) )
{
idVec3 push;
push = hit->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin();

View file

@ -586,8 +586,11 @@ CONSOLE_COMMAND( crash, "causes a crash", NULL )
commonLocal.Printf( "crash may only be used in developer mode\n" );
return;
}
#ifdef __GNUC__
__builtin_trap();
#else
* ( int* ) 0 = 0x12345678;
#endif
}
/*

View file

@ -3215,7 +3215,9 @@ bool idFileSystemLocal::GetResourceCacheEntry( const char* fileName, idResourceC
{
// os path, convert to relative? scripts can pass in an OS path
//idLib::Printf( "RESOURCE: os path passed %s\n", fileName );
return NULL;
// DG: this should return a bool, i.e. false, not NULL
return false;
// DG end
}
else
{
@ -3269,7 +3271,8 @@ idFile* idFileSystemLocal::GetResourceFile( const char* fileName, bool memFile )
idLib::Printf( "RES: loading file %s\n", rc.filename.c_str() );
}
idFile_InnerResource* file = new idFile_InnerResource( rc.filename, resourceFiles[ rc.containerIndex ]->resourceFile, rc.offset, rc.length );
if( file != NULL && ( memFile || rc.length <= resourceBufferAvailable ) || rc.length < 8 * 1024 * 1024 )
// DG: add parenthesis to make sure this block is only entered when file != NULL - bug found by clang.
if( file != NULL && ( ( memFile || rc.length <= resourceBufferAvailable ) || rc.length < 8 * 1024 * 1024 ) )
{
byte* buf = NULL;
if( rc.length < resourceBufferAvailable )

View file

@ -968,7 +968,7 @@ extern int unzReadCurrentFile( unzFile file, void* buf, unsigned len )
return UNZ_PARAMERROR;
if( ( pfile_in_zip_read_info->read_buffer == NULL ) )
if( pfile_in_zip_read_info->read_buffer == NULL ) // DG: remove unnecessary parenthesis
return UNZ_END_OF_LIST_OF_FILE;
if( len == 0 )
return 0;

View file

@ -819,11 +819,11 @@ int zipOpenNewFileInZip3( zipFile file, const char* filename, const zip_fileinfo
{
zi->ci.flag |= 2;
}
if( ( level == 2 ) )
if( level == 2 ) // DG: remove unnecessary parenthesis
{
zi->ci.flag |= 4;
}
if( ( level == 1 ) )
if( level == 1 ) // DG: remove unnecessary parenthesis
{
zi->ci.flag |= 6;
}

View file

@ -66,19 +66,19 @@ void* Mem_ClearedAlloc( const size_t size, const memTag_t tag );
char* Mem_CopyString( const char* in );
// RB end
ID_INLINE void* operator new( size_t s )
ID_INLINE void* operator new( size_t s ) throw( std::bad_alloc ) // DG: standard signature seems to include throw(..)
{
return Mem_Alloc( s, TAG_NEW );
}
ID_INLINE void operator delete( void* p )
ID_INLINE void operator delete( void* p ) throw() // DG: delete musn't throw
{
Mem_Free( p );
}
ID_INLINE void* operator new[]( size_t s )
ID_INLINE void* operator new[]( size_t s ) throw( std::bad_alloc ) // DG: standard signature seems to include throw(..)
{
return Mem_Alloc( s, TAG_NEW );
}
ID_INLINE void operator delete[]( void* p )
ID_INLINE void operator delete[]( void* p ) throw() // DG: delete musn't throw
{
Mem_Free( p );
}
@ -86,7 +86,7 @@ ID_INLINE void* operator new( size_t s, memTag_t tag )
{
return Mem_Alloc( s, tag );
}
ID_INLINE void operator delete( void* p, memTag_t tag )
ID_INLINE void operator delete( void* p, memTag_t tag ) throw() // DG: delete musn't throw
{
Mem_Free( p );
}
@ -94,7 +94,7 @@ ID_INLINE void* operator new[]( size_t s, memTag_t tag )
{
return Mem_Alloc( s, tag );
}
ID_INLINE void operator delete[]( void* p, memTag_t tag )
ID_INLINE void operator delete[]( void* p, memTag_t tag ) throw() // DG: delete musn't throw
{
Mem_Free( p );
}

View file

@ -103,7 +103,7 @@ static const __m128 vector_float_mask3 = __m128c( _mm_set1_epi32( 1 << 3 )
static const __m128 vector_float_mask4 = __m128c( _mm_set1_epi32( 1 << 4 ) );
static const __m128 vector_float_mask5 = __m128c( _mm_set1_epi32( 1 << 5 ) );
static const __m128 vector_float_sign_bit = __m128c( _mm_set1_epi32( IEEE_FLT_SIGN_MASK ) );
static const __m128 vector_float_abs_mask = __m128c( _mm_set1_epi32( ~IEEE_FLT_SIGN_MASK ) );
static const __m128 vector_float_abs_mask = __m128c( _mm_set1_epi32( ~( int )IEEE_FLT_SIGN_MASK ) );
static const __m128 vector_float_keep_last = __m128c( _mm_set_epi32( -1, 0, 0, 0 ) );
static const __m128 vector_float_inverse_epsilon = { RENDER_MATRIX_INVERSE_EPSILON, RENDER_MATRIX_INVERSE_EPSILON, RENDER_MATRIX_INVERSE_EPSILON, RENDER_MATRIX_INVERSE_EPSILON };
static const __m128 vector_float_smallest_non_denorm = { 1.1754944e-038f, 1.1754944e-038f, 1.1754944e-038f, 1.1754944e-038f };
@ -916,7 +916,7 @@ idRenderMatrix::Inverse
inverse( M ) = ( 1 / determinant( M ) ) * transpose( cofactor( M ) )
This code is based on the code written by Cédric Lallain, published on "Cell Performance"
This code is based on the code written by C<EFBFBD>dric Lallain, published on "Cell Performance"
(by Mike Acton) and released under the BSD 3-Clause ("BSD New" or "BSD Simplified") license.
https://code.google.com/p/cellperformance-snippets/

View file

@ -56,7 +56,10 @@ ALIGN16( const __m128 SIMD_SP_LCP_DELTA_FORCE_EPSILON ) = { LCP_DELTA_FORCE_EP
ALIGN16( const __m128 SIMD_SP_LCP_BOUND_EPSILON ) = { LCP_BOUND_EPSILON, LCP_BOUND_EPSILON, LCP_BOUND_EPSILON, LCP_BOUND_EPSILON };
ALIGN16( const __m128 SIMD_SP_neg_LCP_BOUND_EPSILON ) = { -LCP_BOUND_EPSILON, -LCP_BOUND_EPSILON, -LCP_BOUND_EPSILON, -LCP_BOUND_EPSILON };
ALIGN16( const unsigned int SIMD_SP_signBit[4] ) = { IEEE_FLT_SIGN_MASK, IEEE_FLT_SIGN_MASK, IEEE_FLT_SIGN_MASK, IEEE_FLT_SIGN_MASK };
ALIGN16( const unsigned int SIMD_SP_absMask[4] ) = { ~IEEE_FLT_SIGN_MASK, ~IEEE_FLT_SIGN_MASK, ~IEEE_FLT_SIGN_MASK, ~IEEE_FLT_SIGN_MASK };
// DG: cast IEEE_FLT_SIGN_MASK to uint before interting it, as uint and not long values are expected here
#define INV_IEEE_FLT_SIGN_MASK (~((unsigned int)IEEE_FLT_SIGN_MASK))
ALIGN16( const unsigned int SIMD_SP_absMask[4] ) = { INV_IEEE_FLT_SIGN_MASK, INV_IEEE_FLT_SIGN_MASK, INV_IEEE_FLT_SIGN_MASK, INV_IEEE_FLT_SIGN_MASK };
// DG end
ALIGN16( const unsigned int SIMD_SP_indexedStartMask[4][4] ) = { { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0, 0, 0xFFFFFFFF, 0xFFFFFFFF }, { 0, 0, 0, 0xFFFFFFFF } };
ALIGN16( const unsigned int SIMD_SP_indexedEndMask[4][4] ) = { { 0, 0, 0, 0 }, { 0xFFFFFFFF, 0, 0, 0 }, { 0xFFFFFFFF, 0xFFFFFFFF, 0, 0 }, { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0 } };
ALIGN16( const unsigned int SIMD_SP_clearLast1[4] ) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0 };

View file

@ -3735,7 +3735,9 @@ void idDxtEncoder::EmitColorAlphaIndices( const byte* colorBlock, const byte* mi
unsigned int b2 = d1 > d0;
unsigned int b3 = c3 < 128;
result |= ( ( ( b0 & b1 | b3 ) << 1 ) | ( b2 ^ b1 | b3 ) ) << ( i << 1 );
// DG: add some parenthesis to appease (often rightly) warning compiler
result |= ( ( ( ( b0 & b1 ) | b3 ) << 1 ) | ( ( b2 ^ b1 ) | b3 ) ) << ( i << 1 );
// DG end
}
EmitUInt( result );

View file

@ -218,6 +218,11 @@ void idGuiModel::EmitToCurrentView( float modelMatrix[16], bool depthHack )
EmitSurfaces( modelMatrix, modelViewMatrix, depthHack, false /* stereoDepthSort */, true /* link as entity */ );
}
// DG: move function declaration here (=> out of EmitFullScreen() method) because it confused clang
// (and possibly other compilers that just didn't complain and silently made it a float variable
// initialized to something, probably 0.0f)
float GetScreenSeparationForGuis();
// DG end
/*
================
@ -243,7 +248,6 @@ void idGuiModel::EmitFullScreen()
bool stereoEnabled = ( renderSystem->GetStereo3DMode() != STEREO3D_OFF );
if( stereoEnabled )
{
float GetScreenSeparationForGuis();
const float screenSeparation = GetScreenSeparationForGuis();
// this will be negated on the alternate eyes, both rendered each frame

View file

@ -332,7 +332,13 @@ void LZWJobInternal( lzwParm_t* parm, unsigned int dmaTag )
dmaTag = dmaTag;
#ifdef __GNUC__
// DG: remove ALIGN16 for GCC/clang, as they can't use it here and clang gets an error
idLZWCompressor lzwCompressor( parm->ioData->lzwData );
// DG end
#else
ALIGN16( idLZWCompressor lzwCompressor( parm->ioData->lzwData ) );
#endif
if( parm->fragmented )
{

View file

@ -741,6 +741,8 @@ sysEvent_t Sys_GetEvent()
case SDL_WINDOWEVENT_FOCUS_LOST:
GLimp_GrabInput( 0 );
break;
// TODO: SDL_WINDOWEVENT_RESIZED
}
return res_none;

View file

@ -2592,8 +2592,6 @@ idPlayerProfile* idSessionLocal::GetProfileFromMasterLocalUser()
return profile;
}
/*
========================
/*
========================
idSessionLocal::MoveToPressStart

View file

@ -117,7 +117,7 @@ void idEditWindow::CommonInit()
sizeBias = 0;
lastTextLength = 0;
forceScroll = false;
password = NULL;
password = false; // DG: this is a bool, so use false, not NULL
cvar = NULL;
liveUpdate = true;
readonly = false;

View file

@ -2464,7 +2464,9 @@ bool idWindow::ParseRegEntry( const char* name, idTokenParser* src )
work = name;
work.ToLower();
idWinVar* var = GetWinVarByName( work, NULL );
// DG: second argument is a bool, so use false, not NULL
idWinVar* var = GetWinVarByName( work, false );
// DG end
if( var )
{
for( int i = 0; i < NumRegisterVars; i++ )