Skip to content

Commit

Permalink
Trigger compilation errors on warnings (AliceO2Group#5445)
Browse files Browse the repository at this point in the history
* Trigger compilation errors on warnings for default + all + extra
  • Loading branch information
vkucera authored Jul 11, 2024
1 parent 2bd0e14 commit c31daaa
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 13 deletions.
4 changes: 2 additions & 2 deletions PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class FemtoUniverseSHContainer
/// \param ChosenEventType same or mixed event
/// \param maxl Maximum valie of L component of the spherical harmonics
template <bool isMC, typename T>
void AddEventPair(T const& part1, T const& part2, uint8_t ChosenEventType, int maxl)
void AddEventPair(T const& part1, T const& part2, uint8_t ChosenEventType, int /*maxl*/)
{
// int fMaxL = 2;
// int fMaxJM = (2+1)*(2+1);
Expand Down Expand Up @@ -216,7 +216,7 @@ class FemtoUniverseSHContainer
/// Function to fill covariance matrix in 3D histograms
/// \param ChosenEventType same or mixed event
/// \param MaxJM Maximum value of J
void PackCov(uint8_t ChosenEventType, int MaxJM)
void PackCov(uint8_t ChosenEventType, int /*MaxJM*/)
{
if (ChosenEventType == femtoUniverseSHContainer::EventType::same) {
for (int ibin = 1; ibin <= fcovnum->GetNbinsX(); ibin++) {
Expand Down
2 changes: 1 addition & 1 deletion PWGUD/Core/UDHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ bool cleanCalo(T const& bc, aod::Calos& calos, std::vector<float>& /*lims*/, Sli
// -----------------------------------------------------------------------------
// check if all tracks come from same MCCollision
template <typename T>
int64_t sameMCCollision(T tracks, aod::McCollisions mccols, aod::McParticles mcparts)
int64_t sameMCCollision(T tracks, aod::McCollisions, aod::McParticles)
{
int64_t colID = -1;
for (auto const& track : tracks) {
Expand Down
2 changes: 1 addition & 1 deletion PWGUD/Tasks/upcTauCentralBarrelRL.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ struct UpcTauCentralBarrelRL {
} // end fillHistograms

template <typename C, typename Ts>
void fillPIDhistograms(C reconstructedCollision, Ts reconstructedBarrelTracks)
void fillPIDhistograms(C /*reconstructedCollision*/, Ts reconstructedBarrelTracks)
{

if (isFirstReconstructedCollisions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct firstcorrelations {
}

template <typename TCollision, typename TTracks>
void fillQA(TCollision collision, float centrality, TTracks tracks)
void fillQA(TCollision /*collision*/, float /*centrality*/, TTracks /*tracks*/)
{
}

Expand All @@ -50,7 +50,7 @@ struct firstcorrelations {
}

template <typename TTarget, typename TTracks>
void fillCorrelations(TTarget target, TTracks tracks1, TTracks tracks2, float centrality, float posZ)
void fillCorrelations(TTarget /*target*/, TTracks /*tracks1*/, TTracks /*tracks2*/, float /*centrality*/, float /*posZ*/)
{
}

Expand Down
2 changes: 2 additions & 0 deletions cmake/O2PhysicsDefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ function(o2physics_define_options)
option(ENABLE_CASSERT "Enable asserts" OFF)

option(ENABLE_UPGRADES "Enable detectors for upgrades" OFF)

option(O2PHYSICS_WARNINGS_AS_ERRORS "Treat selected warnings as errors" OFF)
endfunction()
54 changes: 47 additions & 7 deletions dependencies/O2PhysicsCompileFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,53 @@

include_guard()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-error \
-Werror=deprecated-enum-float-conversion \
-Werror=narrowing \
-Werror=parentheses \
-Werror=return-type \
-Werror=uninitialized \
-Werror=unused")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")

# Enabled warnings supported by Clang and GCC, not treated as errors
set(O2PHYSICS_WARNINGS_COMMON_NO_ERROR "sign-compare")

# Enabled warnings supported by Clang only, not treated as errors
set(O2PHYSICS_WARNINGS_CLANG_NO_ERROR "")

# Enabled warnings supported by GCC only, not treated as errors
set(O2PHYSICS_WARNINGS_GCC_NO_ERROR "")

# Function to build a list of warning flags from their names
function(o2_build_warning_flags)
cmake_parse_arguments(PARSE_ARGV 0 A "" "PREFIX;OUTPUTVARNAME" "WARNINGS")
if(A_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}")
endif()
list(TRANSFORM A_WARNINGS STRIP)
list(TRANSFORM A_WARNINGS PREPEND ${A_PREFIX})
string(JOIN " " OUTPUT ${A_WARNINGS})
set(${A_OUTPUTVARNAME} ${OUTPUT} PARENT_SCOPE)
endfunction()

message(STATUS "O2PHYSICS_WARNINGS_AS_ERRORS: ${O2PHYSICS_WARNINGS_AS_ERRORS}")

# Treat warnings as errors.
if(O2PHYSICS_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
# Set warning flags for all platforms.
o2_build_warning_flags(PREFIX "-Wno-error="
OUTPUTVARNAME O2PHYSICS_CXX_WARNINGS_COMMON_NO_ERROR
WARNINGS ${O2PHYSICS_WARNINGS_COMMON_NO_ERROR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${O2PHYSICS_CXX_WARNINGS_COMMON_NO_ERROR}")
if(APPLE)
# Set warning flags for macOS only.
o2_build_warning_flags(PREFIX "-Wno-error="
OUTPUTVARNAME O2PHYSICS_CXX_WARNINGS_APPLE_NO_ERROR
WARNINGS ${O2PHYSICS_WARNINGS_CLANG_NO_ERROR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${O2PHYSICS_CXX_WARNINGS_APPLE_NO_ERROR}")
elseif(UNIX)
# Set warning flags for Linux only.
o2_build_warning_flags(PREFIX "-Wno-error="
OUTPUTVARNAME O2PHYSICS_CXX_WARNINGS_UNIX_NO_ERROR
WARNINGS ${O2PHYSICS_WARNINGS_GCC_NO_ERROR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${O2PHYSICS_CXX_WARNINGS_UNIX_NO_ERROR}")
endif()
endif()

IF (ENABLE_TIMETRACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftime-trace")
Expand Down

0 comments on commit c31daaa

Please sign in to comment.