[llvm] f039a2c - [test] Fix aggregate initialization incompatible with c++20

Jordan Rupprecht via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 12:48:49 PST 2022


Author: Samira Bazuzi
Date: 2022-11-30T12:48:42-08:00
New Revision: f039a2cf107a143ea2c0cf3f2a88ec2400421287

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

LOG: [test] Fix aggregate initialization incompatible with c++20

In C++20, types that declare or delete any constructors are no longer aggregates, breaking compilation of many existing uses of aggregate initialization. In this test, provide a one-arg constructor so that `StructWithoutCopyOrMove{1}` still works.

Added: 
    

Modified: 
    llvm/unittests/Support/HashBuilderTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Support/HashBuilderTest.cpp b/llvm/unittests/Support/HashBuilderTest.cpp
index 26007442a339..2e27e4bd25db 100644
--- a/llvm/unittests/Support/HashBuilderTest.cpp
+++ b/llvm/unittests/Support/HashBuilderTest.cpp
@@ -134,6 +134,7 @@ void addHash(llvm::HashBuilderImpl<HasherT, Endianness> &HBuilder,
 struct StructWithoutCopyOrMove {
   int I;
   StructWithoutCopyOrMove() = default;
+  explicit StructWithoutCopyOrMove(int I) : I(I) {}
   StructWithoutCopyOrMove(const StructWithoutCopyOrMove &) = delete;
   StructWithoutCopyOrMove &operator=(const StructWithoutCopyOrMove &) = delete;
 


        


More information about the llvm-commits mailing list