[libcalamares] Avoid warnings / errors on both gcc and clang
- Clang 8 can detect that there is no need for a return if all previous paths already return. GCC 8 does not. Clang warns if the unreachable return is there, GCC errors out if it isn't. - Introduce a hack NOTREACHED that comments-out on Clang, and marks as unreachable (but still present) on GCC. - This might go away with an [[unreachable]] annotation or similar.
This commit is contained in:
parent
c44eaf107f
commit
10ba468748
@ -193,6 +193,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
)
|
||||
string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" )
|
||||
endforeach()
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='//'" )
|
||||
|
||||
# Third-party code where we don't care so much about compiler warnings
|
||||
# (because it's uncomfortable to patch) get different flags; use
|
||||
@ -218,6 +219,8 @@ else()
|
||||
|
||||
set( SUPPRESS_3RDPARTY_WARNINGS "" )
|
||||
set( SUPPRESS_BOOST_WARNINGS "" )
|
||||
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='__builtin_unreachable();'" )
|
||||
endif()
|
||||
|
||||
# Use mark_thirdparty_code() to reduce warnings from the compiler
|
||||
|
@ -113,6 +113,7 @@ create_interface( Handler::Type t, const QString& selector )
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
NOTREACHED return nullptr;
|
||||
}
|
||||
|
||||
static RegionZonePair
|
||||
|
@ -166,6 +166,7 @@ PartitionSize::toBytes() const
|
||||
case SizeUnit::GiB:
|
||||
return CalamaresUtils::GiBtoBytes( static_cast<unsigned long long>( value() ) );
|
||||
}
|
||||
NOTREACHED return -1;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -186,6 +187,7 @@ PartitionSize::operator< ( const PartitionSize& other ) const
|
||||
case SizeUnit::GiB:
|
||||
return ( toBytes() < other.toBytes () );
|
||||
}
|
||||
NOTREACHED return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -206,6 +208,7 @@ PartitionSize::operator> ( const PartitionSize& other ) const
|
||||
case SizeUnit::GiB:
|
||||
return ( toBytes() > other.toBytes () );
|
||||
}
|
||||
NOTREACHED return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -226,6 +229,7 @@ PartitionSize::operator== ( const PartitionSize& other ) const
|
||||
case SizeUnit::GiB:
|
||||
return ( toBytes() == other.toBytes () );
|
||||
}
|
||||
NOTREACHED return false;
|
||||
}
|
||||
|
||||
} // namespace Calamares
|
||||
|
Loading…
Reference in New Issue
Block a user