Skip to content

Commit

Permalink
reduce clang-15 warnings (#4840)
Browse files Browse the repository at this point in the history
* reduce clang-15 warnings

* update bslmf_invokeresult_cpp03.00.t.cpp

* correct warnings
  • Loading branch information
Jeffrey Mendelsohn authored and GitHub Enterprise committed Jul 24, 2024
1 parent 3b41356 commit fe4d1a4
Show file tree
Hide file tree
Showing 43 changed files with 222 additions and 73 deletions.
2 changes: 1 addition & 1 deletion groups/bsl/bslalg/bslalg_arrayprimitives.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ char getValue(const Uint64& u64)

void setValue(float *pf, char ch)
{
*pf = static_cast<int>(ch);
*pf = static_cast<short>(ch);
}

void setValue(double *pf, char ch)
Expand Down
2 changes: 0 additions & 2 deletions groups/bsl/bslalg/bslalg_autoarraydestructor.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ class TestType;
typedef TestType T; // uses 'bslma' allocators

// STATIC DATA
const int MAX_ALIGN = bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT;

static int numDefaultCtorCalls = 0;
static int numCharCtorCalls = 0;
static int numCopyCtorCalls = 0;
Expand Down
2 changes: 1 addition & 1 deletion groups/bsl/bslalg/bslalg_constructorproxy.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class TestType_Base {
// ACCESSORS
allocator_type get_allocator() const { return d_allocator; }

bool matchAllocator(const AllocArg a) const { return a == d_allocator; }
bool matchAllocator(AllocArg a) const { return a == d_allocator; }
bool matchAllocator(bslma::Allocator *a) const
// Return 'true' if the specified 'a' matches the allocator. The
// second overload relies on the fact that most STL allocators used for
Expand Down
5 changes: 4 additions & 1 deletion groups/bsl/bslalg/bslalg_containerbase.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// bslalg_containerbase.t.cpp -*-C++-*-
#include <bslalg_containerbase.h>

#include <bsla_maybeunused.h>

#include <bslma_allocator.h>
#include <bslma_allocatorutil.h>
#include <bslma_autodestructor.h>
Expand Down Expand Up @@ -198,7 +200,8 @@ class StatelessSTLAllocator {
}

void deallocate(value_type *p, std::size_t n) {
bslma::Allocator *rsrc = bslma::Default::defaultAllocator();
BSLA_MAYBE_UNUSED bslma::Allocator *rsrc =
bslma::Default::defaultAllocator();
bslma::AllocatorUtil::deallocateObject(&g_StatelessSTLAllocatorRsrc,
p, n);
}
Expand Down
16 changes: 10 additions & 6 deletions groups/bsl/bslalg/bslalg_dequeprimitives.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,20 @@ class TestDeque : public TestDeque_Type<ALLOCATOR>::AllocatorType
for (int i = 0; i < d_blockNum; ++i) {
size_type numMaxAlignedType =
(sizeof(Block) + MAX_ALIGN - 1) / MAX_ALIGN;
AllocatorTraits::deallocate(allocator(),
(bsls::AlignmentUtil::MaxAlignedType *) d_blocks_p[i],
numMaxAlignedType);
AllocatorTraits::deallocate(
allocator(),
(bsls::AlignmentUtil::MaxAlignedType *)static_cast<void *>(
d_blocks_p[i]),
numMaxAlignedType);
}
size_type numBytes = static_cast<size_type>(sizeof(BlockPtr))
+ d_blockNum;
size_type numMaxAlignedType = (numBytes + MAX_ALIGN - 1) / MAX_ALIGN;
AllocatorTraits::deallocate(allocator(),
(bsls::AlignmentUtil::MaxAlignedType *) d_blocks_p,
numMaxAlignedType);
AllocatorTraits::deallocate(
allocator(),
(bsls::AlignmentUtil::MaxAlignedType *)static_cast<void *>(
d_blocks_p),
numMaxAlignedType);
}

// MANIPULATORS
Expand Down
8 changes: 4 additions & 4 deletions groups/bsl/bslalg/bslalg_rangecompare.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1957,8 +1957,8 @@ void timeEqualAlgorithm(const char *typeName,
printf("\n\tcompare with '%s'\n", typeName);
{
const size_t bufferSize = rawBufferSize / sizeof(TYPE);
TYPE *buffer1 = (TYPE*)rawBuffer1;
TYPE *buffer2 = (TYPE*)rawBuffer2;
TYPE *buffer1 = (TYPE*)static_cast<void *>(rawBuffer1);
TYPE *buffer2 = (TYPE*)static_cast<void *>(rawBuffer2);

for (size_t j = 0; j < bufferSize; ++j) {
buffer1[j] = buffer2[j] = TYPE();
Expand Down Expand Up @@ -2031,8 +2031,8 @@ void timeLexicographicalAlgorithm(const char *typeName,
printf("\n\tcompare with '%s'\n", typeName);
{
const size_t bufferSize = rawBufferSize / sizeof(TYPE);
TYPE *buffer1 = (TYPE*)rawBuffer1;
TYPE *buffer2 = (TYPE*)rawBuffer2;
TYPE *buffer1 = (TYPE*)static_cast<void *>(rawBuffer1);
TYPE *buffer2 = (TYPE*)static_cast<void *>(rawBuffer2);

for (size_t j = 0; j < bufferSize; ++j) {
buffer1[j] = buffer2[j] = TYPE();
Expand Down
9 changes: 6 additions & 3 deletions groups/bsl/bslalg/bslalg_selecttrait.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <bslalg_typetraitpair.h> // for testing only
#include <bslalg_typetraitusesbslmaallocator.h> // for testing only

#include <bsla_maybeunused.h>

#include <bslma_usesbslmaallocator.h>

#include <bslmf_isbitwisemoveable.h>
Expand Down Expand Up @@ -103,9 +105,10 @@ const unsigned TRAIT_HASSTLITERATORS = 0x0040;
const unsigned TRAIT_HASPOINTERSEMANTICS = 0x0080;

// Traits group
const unsigned TRAIT_POD = (TRAIT_BITWISEMOVEABLE |
TRAIT_BITWISECOPYABLE |
TRAIT_HASTRIVIALDEFAULTCONSTRUCTOR);
BSLA_MAYBE_UNUSED const unsigned TRAIT_POD =
(TRAIT_BITWISEMOVEABLE |
TRAIT_BITWISECOPYABLE |
TRAIT_HASTRIVIALDEFAULTCONSTRUCTOR);

template <class TYPE>
unsigned traitBits()
Expand Down
7 changes: 7 additions & 0 deletions groups/bsl/bslalg/bslalg_typetraitbitwisecopyable.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
#include <bslalg_hastrait.h>

#include <bsls_bsltestutil.h>
#include <bsls_platform.h>

#include <stdio.h> // 'printf'
#include <stdlib.h> // 'atoi'

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
#include <bslalg_hastrait.h>

#include <bsls_bsltestutil.h>
#include <bsls_platform.h>

#include <stdio.h> // 'printf'
#include <stdlib.h> // 'atoi'

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions groups/bsl/bslalg/bslalg_typetraitbitwisemoveable.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
#include <bslalg_hastrait.h>

#include <bsls_bsltestutil.h>
#include <bsls_platform.h>

#include <stdio.h> // 'printf'
#include <stdlib.h> // 'atoi'

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
#include <bslalg_hastrait.h>

#include <bsls_bsltestutil.h>
#include <bsls_platform.h>

#include <stdio.h> // 'printf'
#include <stdlib.h> // 'atoi'

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion groups/bsl/bslh/bslh_seededhash.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ bool TypeChecker<EXPECTED_TYPE>::isCorrectType(EXPECTED_TYPE) {

template<class EXPECTED_TYPE>
template<class BDE_OTHER_TYPE>
bool TypeChecker<EXPECTED_TYPE>::isCorrectType(BDE_OTHER_TYPE type) {
bool TypeChecker<EXPECTED_TYPE>::isCorrectType(BDE_OTHER_TYPE /* type */) {
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions groups/bsl/bslim/bslim_bslstandardheadertest.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions groups/bsl/bslma/bslma_allocator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <bsls_alignmentutil.h>
#include <bsls_bsltestutil.h>
#include <bsls_compilerfeatures.h>
#include <bsls_platform.h>
#include <bsls_protocoltest.h>

#include <stdio.h> // 'printf'
Expand All @@ -16,6 +17,12 @@

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions groups/bsl/bslma/bslma_deleterhelper.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <bsls_assert.h>
#include <bsls_asserttest.h>
#include <bsls_bsltestutil.h>
#include <bsls_platform.h>

#include <stdio.h> // 'printf'
#include <stdlib.h> // 'atoi'
Expand All @@ -14,6 +15,12 @@

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
15 changes: 7 additions & 8 deletions groups/bsl/bslma/bslma_managedallocator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ void * LinkedListMA::allocate(size_type size)
// If we got here, there were no blocks that could satisfy the requirement.
// Get truly new memory.
char *newMem = new char[sizeof(Node) + size];
((Node *)newMem)->d_dataSize = size;
((Node *)newMem)->d_next = d_usedList;
d_usedList = (Node *)newMem;
((Node *)static_cast<void *>(newMem))->d_dataSize = size;
((Node *)static_cast<void *>(newMem))->d_next = d_usedList;
d_usedList = (Node *)static_cast<void *>(newMem);

return newMem + DATAOFFSET;
}

void LinkedListMA::deallocate(void *address)
{
changeLists((Node *)((char *)address - DATAOFFSET),
changeLists((Node *)static_cast<void *>((char *)address - DATAOFFSET),
&d_usedList, &d_freeList);
}

Expand Down Expand Up @@ -515,10 +515,9 @@ int main(int argc, char *argv[])
// --------------------------------------------------------------------

const char *sampleStrings[] = {
"Hello", "How are you?", "Es geht mir gut",
"Porque tenemos que trabajar?", "Donde esta el gatito?",
"You get a shiver in the dark/it's raining in the "
"park/but meantime"
"Hello", "How are you?", "Es geht mir gut",
"Porque tenemos que trabajar?", "Donde esta el gatito?",
"You get a shiver in the dark/it's raining in the park/but meantime"
};

const int NUMBER_OF_STRINGS =
Expand Down
3 changes: 1 addition & 2 deletions groups/bsl/bslma/bslma_sequentialpool.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,7 @@ int main(int argc, char *argv[])
blockSize(INITIAL_SIZE * 2) == tc.numBytesInUse());
}
else {
int nextSize = calculateNextSize(abs(INITIAL_SIZE),
SIZE);
int nextSize = calculateNextSize(INITIAL_SIZE, SIZE);
LOOP4_ASSERT(i, SIZE, blockSize(nextSize),
ta.numBytesInUse(),
blockSize(nextSize) == ta.numBytesInUse());
Expand Down
7 changes: 7 additions & 0 deletions groups/bsl/bslma/bslma_sharedptroutofplacerep.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <bsls_asserttest.h>
#include <bsls_bsltestutil.h>
#include <bsls_platform.h>

#include <cstddef> // std::size_t

Expand All @@ -31,6 +32,12 @@

using namespace BloombergLP;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions groups/bsl/bslma/bslma_testallocator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,8 @@ int main(int argc, char *argv[])
if (verbose) printf(
"\t[deallocate pointer + sizeof(size_type)]\n");
if (veryVerbose) puts(LINE);
a.deallocate((bslma::Allocator::size_type *)p + 1);
a.deallocate((bslma::Allocator::size_type *)
static_cast<void *>(p) + 1);
if (veryVerbose) puts(LINE);
ASSERT(1 == a.numBlocksInUse());
ASSERT(3 == a.numBytesInUse());
Expand All @@ -2428,7 +2429,8 @@ int main(int argc, char *argv[])
if (verbose) printf(
"\t[deallocate pointer - sizeof(size_type)]\n");
if (veryVerbose) puts(LINE);
a.deallocate((bslma::Allocator::size_type *)p - 1);
a.deallocate((bslma::Allocator::size_type *)
static_cast<void *>(p) - 1);
if (veryVerbose) puts(LINE);
ASSERT(1 == a.numBlocksInUse());
ASSERT(3 == a.numBytesInUse());
Expand Down
6 changes: 6 additions & 0 deletions groups/bsl/bslmf/bslmf_forwardingreftype.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ using namespace BloombergLP;
#pragma error_messages(off, SEC_UNINITIALIZED_MEM_READ)
#endif

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wdeprecated-volatile"
#endif
#endif

// Suppress bde_verify messages about all-uppercase type names. Test drivers
// are rife with short names like 'F' or 'PF' or 'T' or 'T1'.

Expand Down
6 changes: 6 additions & 0 deletions groups/bsl/bslmf/bslmf_forwardingtype.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ using namespace BloombergLP;
#pragma error_messages(off, SEC_UNINITIALIZED_MEM_READ)
#endif

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wdeprecated-volatile"
#endif
#endif

// Suppress bde_verify messages about all-uppercase type names. Test drivers
// are rife with short names like 'F' or 'PF' or 'T' or 'T1'.

Expand Down
5 changes: 5 additions & 0 deletions groups/bsl/bslmf/bslmf_invokeresult.00.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
# pragma error_messages(off, functypequal)
#endif

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wdeprecated-volatile"
#endif
#endif

using namespace BloombergLP;

Expand Down
Loading

0 comments on commit fe4d1a4

Please sign in to comment.