diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp index 68b8db06be..d027624dbc 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp @@ -75,7 +75,7 @@ void MidiKeyboardState::noteOnInternal (const int midiChannel, const int midiNo { if (isPositiveAndBelow (midiNoteNumber, 128)) { - noteStates [midiNoteNumber] |= (1 << (midiChannel - 1)); + noteStates[midiNoteNumber] = static_cast (noteStates[midiNoteNumber] | (1 << (midiChannel - 1))); for (int i = listeners.size(); --i >= 0;) listeners.getUnchecked(i)->handleNoteOn (this, midiChannel, midiNoteNumber, velocity); @@ -100,7 +100,7 @@ void MidiKeyboardState::noteOffInternal (const int midiChannel, const int midiN { if (isNoteOn (midiChannel, midiNoteNumber)) { - noteStates [midiNoteNumber] &= ~(1 << (midiChannel - 1)); + noteStates[midiNoteNumber] = static_cast (noteStates[midiNoteNumber] & ~(1 << (midiChannel - 1))); for (int i = listeners.size(); --i >= 0;) listeners.getUnchecked(i)->handleNoteOff (this, midiChannel, midiNoteNumber, velocity); diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h index 47aaf6923c..96c5b65488 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h @@ -193,7 +193,7 @@ public: private: //============================================================================== CriticalSection lock; - uint16 noteStates [128]; + uint16 noteStates[128]; MidiBuffer eventsToAdd; Array listeners; diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index 7d750c9b7f..e6802e9528 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -335,7 +335,7 @@ namespace AiffFileHelpers out.writeIntBigEndian (offset); auto labelLength = jmin ((size_t) 254, label.getNumBytesAsUTF8()); // seems to need null terminator even though it's a pstring - out.writeByte ((char) labelLength + 1); + out.writeByte (static_cast (labelLength + 1)); out.write (label.toUTF8(), labelLength); out.writeByte (0); @@ -368,7 +368,7 @@ namespace AiffFileHelpers auto comment = values.getValue (prefix + "Text", String()); auto commentLength = jmin (comment.getNumBytesAsUTF8(), (size_t) 65534); - out.writeShortBigEndian ((short) commentLength + 1); + out.writeShortBigEndian (static_cast (commentLength + 1)); out.write (comment.toUTF8(), commentLength); out.writeByte (0); diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index f824012e74..4d8d2c9dd7 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -43,6 +43,7 @@ namespace OggVorbisNamespace #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wshadow" + #pragma clang diagnostic ignored "-Wfloat-conversion" #pragma clang diagnostic ignored "-Wdeprecated-register" #pragma clang diagnostic ignored "-Wswitch-enum" #if __has_warning("-Wzero-as-null-pointer-constant") @@ -53,6 +54,7 @@ namespace OggVorbisNamespace #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wfloat-conversion" #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #pragma GCC diagnostic ignored "-Wswitch-enum" #pragma GCC diagnostic ignored "-Wswitch-default" @@ -212,7 +214,7 @@ public: while (numToRead > 0) { float** dataIn = nullptr; - auto samps = ov_read_float (&ovFile, &dataIn, numToRead, &bitStream); + auto samps = static_cast (ov_read_float (&ovFile, &dataIn, numToRead, &bitStream)); if (samps <= 0) break; diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h index 445a06e18c..1e91ae4274 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h @@ -238,7 +238,7 @@ struct Program auto n = (uint16) size; for (uint32 i = 2; i < size; ++i) - n += (n * 2) + programStart[i]; + n = static_cast (n + (n * 2) + programStart[i]); return n; } diff --git a/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h b/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h index fe2eadb4c2..f7807e1e9c 100644 --- a/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h +++ b/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h @@ -39,7 +39,7 @@ static uint8 calculatePacketChecksum (const uint8* data, uint32 size) noexcept uint8 checksum = (uint8) size; for (uint32 i = 0; i < size; ++i) - checksum += checksum * 2 + data[i]; + checksum = static_cast (checksum + (checksum * 2 + data[i])); return checksum & 0x7f; } @@ -181,7 +181,7 @@ struct Packed7BitArrayBuilder { const int bitsToDo = jmin (7 - bitsInCurrentByte, numBits); - data[bytesWritten] |= ((value & (uint32) ((1 << bitsToDo) - 1)) << bitsInCurrentByte); + data[bytesWritten] = static_cast (data[bytesWritten] | ((value & (uint32) ((1 << bitsToDo) - 1)) << bitsInCurrentByte)); value >>= bitsToDo; numBits -= bitsToDo; bitsInCurrentByte += bitsToDo; diff --git a/modules/juce_box2d/juce_box2d.cpp b/modules/juce_box2d/juce_box2d.cpp index 981c908330..0a550c4ee3 100644 --- a/modules/juce_box2d/juce_box2d.cpp +++ b/modules/juce_box2d/juce_box2d.cpp @@ -37,6 +37,7 @@ #if defined JUCE_CLANG #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" #pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wfloat-conversion" #pragma clang diagnostic ignored "-Wcast-align" @@ -46,7 +47,9 @@ #endif #elif defined JUCE_GCC #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wfloat-conversion" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #pragma GCC diagnostic ignored "-Wswitch-enum" diff --git a/modules/juce_core/maths/juce_BigInteger.cpp b/modules/juce_core/maths/juce_BigInteger.cpp index fae2e2f09f..45fcae53da 100644 --- a/modules/juce_core/maths/juce_BigInteger.cpp +++ b/modules/juce_core/maths/juce_BigInteger.cpp @@ -551,7 +551,7 @@ BigInteger& BigInteger::operator*= (const BigInteger& other) { auto uv = (uint64) totalValues[i + j] + (uint64) values[j] * (uint64) mValues[i] + (uint64) c; totalValues[i + j] = (uint32) uv; - c = uv >> 32; + c = static_cast (uv >> 32); } totalValues[i + n + 1] = c; diff --git a/modules/juce_core/network/juce_IPAddress.cpp b/modules/juce_core/network/juce_IPAddress.cpp index 35b34431c5..e4f1f8966b 100644 --- a/modules/juce_core/network/juce_IPAddress.cpp +++ b/modules/juce_core/network/juce_IPAddress.cpp @@ -90,10 +90,10 @@ IPAddress::IPAddress (uint16 a1, uint16 a2, uint16 a3, uint16 a4, IPAddress::IPAddress (uint32 n) noexcept : isIPv6 (false) { - address[0] = (n >> 24); - address[1] = (n >> 16) & 255; - address[2] = (n >> 8) & 255; - address[3] = (n & 255); + address[0] = static_cast (n >> 24); + address[1] = static_cast ((n >> 16) & 255); + address[2] = static_cast ((n >> 8) & 255); + address[3] = static_cast ((n & 255)); zeroUnusedBytes (address); } diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index 1e28be5a61..e8df43b96e 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -265,7 +265,7 @@ namespace SocketHelpers break; } - bytesRead += bytesThisTime; + bytesRead = static_cast (bytesRead + bytesThisTime); if (! blockUntilSpecifiedAmountHasArrived) break; diff --git a/modules/juce_core/text/juce_CharPointer_UTF8.h b/modules/juce_core/text/juce_CharPointer_UTF8.h index 09b86325ca..8df23f7021 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -124,7 +124,7 @@ public: while ((static_cast (n) & bit) != 0 && bit > 0x8) { ++data; - bit >>= 1; + bit = static_cast (bit >> 1); } } diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 1681c2c216..77f01787d3 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -393,7 +393,7 @@ namespace NumberToStringConverters do { - *--t = '0' + (char) (v % 10); + *--t = static_cast ('0' + (char) (v % 10)); v /= 10; } while (v > 0); @@ -1912,7 +1912,7 @@ static String hexToString (Type v) do { *--t = hexDigits [(int) (v & 15)]; - v >>= 4; + v = static_cast (v >> 4); } while (v != 0); diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index 37692d0d44..863db0596e 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -577,7 +577,7 @@ private: target.writeInt ((int) checksum); target.writeInt ((int) (uint32) compressedSize); target.writeInt ((int) (uint32) uncompressedSize); - target.writeShort ((short) storedPathname.toUTF8().sizeInBytes() - 1); + target.writeShort (static_cast (storedPathname.toUTF8().sizeInBytes() - 1)); target.writeShort (0); // extra field length } diff --git a/modules/juce_cryptography/encryption/juce_BlowFish.cpp b/modules/juce_cryptography/encryption/juce_BlowFish.cpp index fb4fa22e53..38a1431411 100644 --- a/modules/juce_cryptography/encryption/juce_BlowFish.cpp +++ b/modules/juce_cryptography/encryption/juce_BlowFish.cpp @@ -338,7 +338,7 @@ bool BlowFish::apply (void* data, size_t size, void (BlowFish::*op) (uint32&, ui int BlowFish::pad (void* data, size_t size, size_t bufferSize) noexcept { // add padding according to https://tools.ietf.org/html/rfc2898#section-6.1.1 - const uint8 paddingSize = 8u - (size % 8u); + const uint8 paddingSize = static_cast (8u - (size % 8u)); auto n = size + paddingSize; if (n > bufferSize) diff --git a/modules/juce_cryptography/hashing/juce_Whirlpool.cpp b/modules/juce_cryptography/hashing/juce_Whirlpool.cpp index 7365fe76e0..478081ff3a 100644 --- a/modules/juce_cryptography/hashing/juce_Whirlpool.cpp +++ b/modules/juce_cryptography/hashing/juce_Whirlpool.cpp @@ -93,7 +93,7 @@ private: bufferBits = bufferPos = 0; } - buffer[bufferPos] = (uint8_t) (b << (8 - bufferRem)); + buffer[bufferPos] = static_cast (b << (8 - bufferRem)); bufferBits += bufferRem; numBits -= 8; @@ -103,7 +103,7 @@ private: if (numBits > 0) { b = (source[sourcePos] << sourceGap) & 0xff; - buffer[bufferPos] |= (b >> bufferRem); + buffer[bufferPos] = static_cast (buffer[bufferPos] | (b >> bufferRem)); } else { @@ -126,7 +126,7 @@ private: bufferBits = bufferPos = 0; } - buffer[bufferPos] = (uint8_t) (b << (8 - bufferRem)); + buffer[bufferPos] = static_cast (b << (8 - bufferRem)); bufferBits += numBits; } } @@ -134,7 +134,8 @@ private: void finalize (uint8_t* result) noexcept { // append a '1'-bit - buffer[bufferPos++] |= 0x80u >> (bufferBits & 7); + buffer[bufferPos] = static_cast (buffer[bufferPos] | (0x80u >> (bufferBits & 7))); + bufferPos++; // pad with zero bits to complete (N*(64*8) - (32*8)) bits if (bufferPos > 32) diff --git a/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h b/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h index e45b32e6c7..9c117c9a91 100644 --- a/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h @@ -115,7 +115,7 @@ struct SIMDFallbackOps auto retval = static_cast (0); for (size_t i = 0; i < n; ++i) - retval += a.s[i]; + retval = static_cast (retval + a.s[i]); return retval; } diff --git a/modules/juce_graphics/colour/juce_Colour.cpp b/modules/juce_graphics/colour/juce_Colour.cpp index c9634ec9c0..2ea7d09a52 100644 --- a/modules/juce_graphics/colour/juce_Colour.cpp +++ b/modules/juce_graphics/colour/juce_Colour.cpp @@ -145,7 +145,10 @@ bool Colour::operator!= (const Colour& other) const noexcept { return argb.ge //============================================================================== Colour::Colour (const uint32 col) noexcept - : argb ((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff) + : argb (static_cast ((col >> 24) & 0xff), + static_cast ((col >> 16) & 0xff), + static_cast ((col >> 8) & 0xff), + static_cast (col & 0xff)) { } diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index a1ed2b1950..9218569e28 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -1757,7 +1757,7 @@ public: case XK_Delete: case XK_Insert: keyPressed = true; - keyCode = (keyCode & 0xff) | Keys::extendedKeyModifier; + keyCode = static_cast ((keyCode & 0xff) | Keys::extendedKeyModifier); break; case XK_Tab: @@ -1777,7 +1777,7 @@ public: if (sym >= XK_F1 && sym <= XK_F35) { keyPressed = true; - keyCode = (sym & 0xff) | Keys::extendedKeyModifier; + keyCode = static_cast ((sym & 0xff) | Keys::extendedKeyModifier); } break; } @@ -2436,9 +2436,9 @@ private: const int keybit = (1 << (keycode & 7)); if (press) - Keys::keyStates [keybyte] |= keybit; + Keys::keyStates[keybyte] = static_cast (Keys::keyStates[keybyte] | keybit); else - Keys::keyStates [keybyte] &= ~keybit; + Keys::keyStates[keybyte] = static_cast (Keys::keyStates[keybyte] & ~keybit); } static void updateKeyModifiers (int status) noexcept