Cleanup some compiler warnings
This commit is contained in:
parent
2cfd6ba978
commit
c27207500d
|
@ -124,6 +124,7 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
|||
message( STATUS "Enabling warning -Wsign-compare" )
|
||||
endif()
|
||||
|
||||
|
||||
# Warn about missing initializers in construction
|
||||
CHECK_CXX_COMPILER_FLAG( "-Wmissing-field-initializers" COMPILER_SUPPORTS_WMISSING_INIT )
|
||||
|
||||
|
@ -133,4 +134,30 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
|||
endif()
|
||||
|
||||
|
||||
# Warn about empty if/for/while bodies
|
||||
CHECK_CXX_COMPILER_FLAG( "-Wempty-body" COMPILER_SUPPORTS_WEMPTY_BODY )
|
||||
|
||||
if( COMPILER_SUPPORTS_WEMPTY_BODY )
|
||||
set( WARN_FLAGS_CXX "${WARN_FLAGS_CXX} -Wempty-body" )
|
||||
message( STATUS "Enabling warning -Wempty-body" )
|
||||
endif()
|
||||
|
||||
|
||||
# Warn about out of order intialization
|
||||
CHECK_CXX_COMPILER_FLAG( "-Wreorder" COMPILER_SUPPORTS_WREORDER )
|
||||
|
||||
if( COMPILER_SUPPORTS_WREORDER )
|
||||
set( WARN_FLAGS_CXX "${WARN_FLAGS_CXX} -Wreorder" )
|
||||
message( STATUS "Enabling warning -Wreorder" )
|
||||
endif()
|
||||
|
||||
|
||||
# Warn about mismatched class/struct declarations
|
||||
CHECK_CXX_COMPILER_FLAG( "-Wmismatched-tags" COMPILER_SUPPORTS_WMISMATCHED_TAGS )
|
||||
|
||||
if( COMPILER_SUPPORTS_WMISMATCHED_TAGS )
|
||||
set( WARN_FLAGS_CXX "${WARN_FLAGS_CXX} -Wmismatched-tags" )
|
||||
message( STATUS "Enabling warning -Wmismatched-tags" )
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
|
|
@ -52,6 +52,12 @@ template <typename T> inline const T& Clamp( const T& lower, const T& value, con
|
|||
return value;
|
||||
}
|
||||
|
||||
// Surpress an annoying warning that the explicit rounding we do is not precise
|
||||
#if defined( __GNUC__ ) || defined( __CLANG__ )
|
||||
_Pragma( "GCC diagnostic push" ) \
|
||||
_Pragma( "GCC diagnostic ignored \"-Wimplicit-int-float-conversion\"" )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Round a floating point number to an integer using "round halfway cases away from zero".
|
||||
*
|
||||
|
@ -74,6 +80,10 @@ constexpr ret_type KiROUND( fp_type v )
|
|||
return ret_type( max_ret( ret ) );
|
||||
}
|
||||
|
||||
#if defined( __GNUC__ ) || defined( __CLANG__ )
|
||||
_Pragma( "GCC diagnostic pop" )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Function rescale()
|
||||
*
|
||||
|
|
|
@ -113,7 +113,7 @@ bool DIALOG_PNS_LENGTH_TUNING_SETTINGS::AcceptOptions( )
|
|||
return false;
|
||||
if( !m_spacing.Validate( 0, std::numeric_limits<int>::max() ) )
|
||||
return false;
|
||||
if( !m_targetLength.Validate( 0, std::numeric_limits<long long int>::max() ) )
|
||||
if( !m_targetLength.Validate( 0, static_cast<double>( std::numeric_limits<long long int>::max() ) ) )
|
||||
return false;
|
||||
if( !m_radius.Validate( 0, 100 ) )
|
||||
return false;
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
static inline long parseInt( const wxString& aValue, double aScalar )
|
||||
{
|
||||
double value = LONG_MAX;
|
||||
double value = std::numeric_limits<double>::max();
|
||||
|
||||
/*
|
||||
* In 2011 gEDA/pcb introduced values with units, like "10mm" or "200mil".
|
||||
|
@ -87,7 +87,7 @@ static inline long parseInt( const wxString& aValue, double aScalar )
|
|||
// This conversion reports failure on strings as simple as "1000", still
|
||||
// it returns the right result in &value. Thus, ignore the return value.
|
||||
aValue.ToCDouble(&value);
|
||||
if( value == LONG_MAX ) // conversion really failed
|
||||
if( value == std::numeric_limits<double>::max() ) // conversion really failed
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "Cannot convert \"%s\" to an integer" ),
|
||||
aValue.GetData() ) );
|
||||
|
|
Loading…
Reference in New Issue