try to avoid certain warnings in tests

Our tests do explicitly trigger certain "bad" cases. And compilers are
getting increasingly smarter, so they start giving us warnings. People
dislike warnings, so lets try to disable them specifically for unit
tests.

Refers to issue #1401
This commit is contained in:
Aliaksey Kandratsenka 2023-07-13 18:15:25 -04:00
parent e63d2f855d
commit 5a3a324459
3 changed files with 26 additions and 1 deletions

View File

@ -63,3 +63,25 @@
#else
# define PERFTOOLS_DLL_DECL // if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
#endif
#if defined(__clang__)
#if __has_warning("-Wuse-after-free")
#pragma clang diagnostic ignored "-Wuse-after-free"
#endif
#if __has_warning("-Wunused-result")
#pragma clang diagnostic ignored "-Wunused-result"
#endif
#if __has_warning("-Wunused-private-field")
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif
#if __has_warning("-Wimplicit-exception-spec-mismatch")
#pragma clang diagnostic ignored "-Wimplicit-exception-spec-mismatch"
#endif
#if __has_warning("-Wmissing-exception-spec")
#pragma clang diagnostic ignored "-Wmissing-exception-spec"
#endif
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
#pragma GCC diagnostic ignored "-Wuse-after-free"
#pragma GCC diagnostic ignored "-Wunused-result"
#endif

View File

@ -31,6 +31,8 @@
// ---
// Author: Fred Akalin
#include "config_for_unittests.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // for memcmp

View File

@ -9,7 +9,8 @@
//
// This file contains the unit tests for profile-handler.h interface.
#include "config.h"
#include "config_for_unittests.h"
#include "profile-handler.h"
#include <atomic>