[clang] 2b97fe2 - [clang][Interp][NFC] Add more tests for bitfield initializers

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 02:46:56 PDT 2023


Author: Timm Bäder
Date: 2023-10-19T11:46:43+02:00
New Revision: 2b97fe2e5158d3803c6d45a38e72c9cd308e2daf

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

LOG: [clang][Interp][NFC] Add more tests for bitfield initializers

Added: 
    

Modified: 
    clang/test/AST/Interp/bitfields.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/AST/Interp/bitfields.cpp b/clang/test/AST/Interp/bitfields.cpp
index 9a144e2f0d9610e..d3a8a083063ab47 100644
--- a/clang/test/AST/Interp/bitfields.cpp
+++ b/clang/test/AST/Interp/bitfields.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -Wno-bitfield-constant-conversion -verify %s
 // RUN: %clang_cc1 -verify=ref -Wno-bitfield-constant-conversion %s
+// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -Wno-bitfield-constant-conversion -verify %s
+// RUN: %clang_cc1 -std=c++20 -verify=ref -Wno-bitfield-constant-conversion %s
 
 // expected-no-diagnostics
 // ref-no-diagnostics
@@ -31,6 +33,27 @@ namespace Basic {
     return a.a = 10;
   }
   static_assert(storeA2() == 2, "");
+
+#if __cplusplus >= 202002
+  struct Init1 {
+    unsigned a : 2 = 1;
+  };
+  constexpr Init1 I1{};
+  static_assert(I1.a == 1, "");
+
+  struct Init2 {
+    unsigned a : 2 = 100;
+  };
+  constexpr Init2 I2{};
+  static_assert(I2.a == 0, "");
+#endif
+
+  struct Init3 {
+    unsigned a : 2;
+    constexpr Init3() : a(100) {}
+  };
+  constexpr Init3 I3{};
+  static_assert(I3.a == 0, "");
 }
 
 namespace Overflow {


        


More information about the cfe-commits mailing list