[clang] 12c4be1 - [clang][unittests] On Windows, silence warning when building with MSVC

Alexandre Ganea via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 11 14:51:01 PDT 2025


Author: Alexandre Ganea
Date: 2025-04-11T17:50:14-04:00
New Revision: 12c4be1ba8513b4c0f43945c0f266d7f871a978a

URL: https://github.com/llvm/llvm-project/commit/12c4be1ba8513b4c0f43945c0f266d7f871a978a
DIFF: https://github.com/llvm/llvm-project/commit/12c4be1ba8513b4c0f43945c0f266d7f871a978a.diff

LOG: [clang][unittests] On Windows, silence warning when building with MSVC

Fixes:
```
[113/324] Building CXX object tools\clang\unittests\AST\ByteCode\CMakeFiles\InterpTests.dir\BitcastBuffer.cpp.obj
C:\git\llvm-project\clang\unittests\AST\ByteCode\BitcastBuffer.cpp(52): warning C4309: 'initializing': truncation of constant value
C:\git\llvm-project\clang\unittests\AST\ByteCode\BitcastBuffer.cpp(53): warning C4309: 'initializing': truncation of constant value
```

Added: 
    

Modified: 
    clang/unittests/AST/ByteCode/BitcastBuffer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/AST/ByteCode/BitcastBuffer.cpp b/clang/unittests/AST/ByteCode/BitcastBuffer.cpp
index 02c38a2201363..f4abbcbb8e84f 100644
--- a/clang/unittests/AST/ByteCode/BitcastBuffer.cpp
+++ b/clang/unittests/AST/ByteCode/BitcastBuffer.cpp
@@ -49,8 +49,8 @@ TEST(BitcastBuffer, PushData) {
 
   BitcastBuffer Buff2(Bytes(sizeof(int)).toBits());
   {
-    short s1 = 0xCAFE;
-    short s2 = 0xBABE;
+    short s1 = (short)0xCAFE;
+    short s2 = (short)0xBABE;
     std::byte sdata[2];
 
     std::memcpy(sdata, &s1, sizeof(s1));


        


More information about the cfe-commits mailing list