From 19e413d3d1783a2ba327e2ce1ed7d2385a02d124 Mon Sep 17 00:00:00 2001 From: dk949 <56653556+dk949@users.noreply.github.com> Date: Wed, 17 Jan 2024 01:00:35 +0000 Subject: [PATCH 1/2] Added -Wsuggest-override to the warning list This warning is available on GCC since 5.1 and Clang since 11.0.0. Since GCC 9.2 it also does not warn if 'final' is used instead of 'override'. This was the case in Clang since the warning was introduced. --- cmake/CompilerWarnings.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index edb526ad..d14daf02 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -56,6 +56,7 @@ function( -Wdouble-promotion # warn if float is implicit promoted to double -Wformat=2 # warn on security issues around functions that format output (ie printf) -Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation + -Wsuggest-override # warn if an overridden member function is not marked 'override' or 'final' ) endif() From 5befd228475b8b0369d97d67dda53a7093f952be Mon Sep 17 00:00:00 2001 From: dk949 <56653556+dk949@users.noreply.github.com> Date: Wed, 17 Jan 2024 01:21:01 +0000 Subject: [PATCH 2/2] Moved suggest-override to the GCC only section I did not realise Clang 6 was the earliest supported Clang version. --- cmake/CompilerWarnings.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index d14daf02..281ea1b2 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -56,7 +56,6 @@ function( -Wdouble-promotion # warn if float is implicit promoted to double -Wformat=2 # warn on security issues around functions that format output (ie printf) -Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation - -Wsuggest-override # warn if an overridden member function is not marked 'override' or 'final' ) endif() @@ -68,6 +67,7 @@ function( -Wduplicated-branches # warn if if / else branches have duplicated code -Wlogical-op # warn about logical operations being used where bitwise were probably wanted -Wuseless-cast # warn if you perform a cast to the same type + -Wsuggest-override # warn if an overridden member function is not marked 'override' or 'final' ) endif()