mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Only suggest final when using non-LTO builds
In LTO builds GCC issues the suggestion-warning from linking stage, when pragmas are already gone and do nothing.
This commit is contained in:
@@ -122,16 +122,6 @@ if (ENABLE_LIGHTFX)
|
||||
add_definitions(-D__ENABLE_LIGHTFX__)
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_TYPES)
|
||||
# Disable -Wsuggest-final-types via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_TYPES__)
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_METHODS)
|
||||
# Disable -Wsuggest-final-methods via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
||||
endif ()
|
||||
|
||||
if (NOT DISABLE_DISCORD_RPC)
|
||||
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
||||
# Don't build discord's examples, some of which are in C and do not honour
|
||||
@@ -202,8 +192,6 @@ if (MSVC)
|
||||
add_definitions(-DNOMINMAX)
|
||||
else ()
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_TYPES -Wsuggest-final-types)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_METHODS -Wsuggest-final-methods)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_OVERRIDE -Wsuggest-override)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DUPLICATED_COND -Wduplicated-cond)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NON_VIRTUAL_DTOR -Wnon-virtual-dtor)
|
||||
@@ -224,6 +212,11 @@ else ()
|
||||
# Do not enable for MinGW, as its headers contain redundant declarations of builtin functions
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
|
||||
endif ()
|
||||
# These have no workarounds available when building with LTO
|
||||
if (NOT IPO_BUILD_ENABLED)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_TYPES -Wsuggest-final-types)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_METHODS -Wsuggest-final-methods)
|
||||
endif ()
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_IGNORED_QUALIFIERS -Wignored-qualifiers)
|
||||
|
||||
# -Wstrict-overflow is only active when -fstrict-overflow is enabled, but -fstrict-overflow
|
||||
@@ -254,6 +247,16 @@ else ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_TYPES)
|
||||
# Disable -Wsuggest-final-types via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_TYPES__)
|
||||
endif ()
|
||||
|
||||
if (CXX_WARN_SUGGEST_FINAL_METHODS)
|
||||
# Disable -Wsuggest-final-methods via pragmas where due.
|
||||
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
||||
endif ()
|
||||
|
||||
# Include sub-projects
|
||||
include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE)
|
||||
include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace OpenRCT2::Audio
|
||||
{
|
||||
class AudioContext : public IAudioContext
|
||||
class AudioContext final : public IAudioContext
|
||||
{
|
||||
private:
|
||||
IAudioMixer* _audioMixer = nullptr;
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class OpenGLDrawingEngine : public IDrawingEngine
|
||||
class OpenGLDrawingEngine final : public IDrawingEngine
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<IUiContext> const _uiContext;
|
||||
|
||||
@@ -79,7 +79,7 @@ using namespace OpenRCT2::Ui;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Context : public IContext
|
||||
class Context final : public IContext
|
||||
{
|
||||
private:
|
||||
// Dependencies
|
||||
|
||||
@@ -109,7 +109,7 @@ struct GameStateSnapshot_t
|
||||
}
|
||||
};
|
||||
|
||||
struct GameStateSnapshots : public IGameStateSnapshots
|
||||
struct GameStateSnapshots final : public IGameStateSnapshots
|
||||
{
|
||||
virtual void Reset() override final
|
||||
{
|
||||
|
||||
@@ -297,7 +297,7 @@ namespace GameActions
|
||||
return #cls; \
|
||||
} \
|
||||
}; \
|
||||
struct cls : public GameActionBase<id, res>
|
||||
struct cls final : public GameActionBase<id, res>
|
||||
// clang-format on
|
||||
|
||||
} // namespace GameActions
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
_origin.direction &= 3;
|
||||
}
|
||||
|
||||
uint16_t GetActionFlags() const override
|
||||
uint16_t GetActionFlags() const override final
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,12 @@ enum
|
||||
STREAM_SEEK_END
|
||||
};
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-types"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Represents a stream that can be read or written to. Implemented by types such as FileStream, NetworkStream or MemoryStream.
|
||||
*/
|
||||
@@ -199,6 +205,10 @@ interface IStream
|
||||
void WriteString(const std::string& string);
|
||||
};
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
class IOException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -85,7 +85,16 @@ namespace OpenRCT2
|
||||
|
||||
public:
|
||||
explicit X8DrawingEngine(const std::shared_ptr<Ui::IUiContext>& uiContext);
|
||||
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
||||
# pragma GCC diagnostic ignored "-Wsuggest-final-types"
|
||||
#endif
|
||||
~X8DrawingEngine() override;
|
||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
void Initialise() override;
|
||||
void Resize(uint32_t width, uint32_t height) override;
|
||||
|
||||
Reference in New Issue
Block a user