Skip to content

Commit

Permalink
Only disable compiler warnings when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbunnyru committed Nov 20, 2024
1 parent f7c4977 commit 37959d8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions libmamba/ext/solv-cpp/src/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,19 @@ namespace solv
{
// This function is only used in `assert()` expressions
// That's why it might get reported as unused in Release builds
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif

auto is_reldep(::Id id) -> bool
{
return ISRELDEP(static_cast<std::make_unsigned_t<::Id>>(id)) != 0;
}

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}

auto ObjPoolView::get_string(StringId id) const -> std::string_view
Expand Down
4 changes: 4 additions & 0 deletions libmamba/src/core/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ namespace mamba

// This ctor only uses proc_dir_lock in `assert()` expression
// That's why it might get reported as unused in Release builds
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

ScopedProcFile::ScopedProcFile(
const Context& context,
Expand Down Expand Up @@ -222,7 +224,9 @@ namespace mamba
pid_file << file_json;
}

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

ScopedProcFile::~ScopedProcFile()
{
Expand Down
10 changes: 7 additions & 3 deletions libmamba/src/core/thread_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ namespace mamba
#ifndef _WIN32
namespace
{
// `sigaddset` might be implemented as a macro calling `__sigbits(int)` function
// At the same time `sigset_t` might be `unsigned int`
// This causes compiler warning
#if defined(__APPLE__) && defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif

// `sigaddset` might be implemented as a macro calling `__sigbits(int)` function
// At the same time `sigset_t` might be `unsigned int`
// This causes compiler warning
sigset_t get_sigset()
{
// block signals in this thread and subsequently
Expand All @@ -46,7 +48,9 @@ namespace mamba
return sigset;
}

#if defined(__APPLE__) && defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

std::thread::native_handle_type sig_recv_thread;
std::atomic<bool> receiver_exists(false);
Expand Down
4 changes: 4 additions & 0 deletions libmamba/src/core/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,10 @@ namespace mamba

// This function is only used in `assert()` expressions
// That's why it might get reported as unused in Release builds
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif

bool is_lockfile_locked(const LockFileOwner& lockfile)
{
Expand All @@ -986,7 +988,9 @@ namespace mamba
#endif
}

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

class LockedFilesRegistry
{
Expand Down
4 changes: 2 additions & 2 deletions libmamba/src/solver/problems_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ namespace mamba::solver
}

// GCC reports dangling reference when using std::invoke with data members
#ifdef __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
Expand Down Expand Up @@ -334,7 +334,7 @@ namespace mamba::solver
}
}

#ifdef __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

Expand Down

0 comments on commit 37959d8

Please sign in to comment.