Timm =?utf-8?q?Bäder?= <[email protected]>,
Timm =?utf-8?q?Bäder?= <[email protected]>,
Timm =?utf-8?q?Bäder?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -255,3 +255,54 @@ namespace ImplicitValueInit {
constexpr Ints2 ints22; // expected-error {{without a user-provided default
constructor}}
static_assert(ints22.m == 0);
}
+
+namespace Ctors {
+
+ struct K {
+ int k;
+ constexpr K(int k) : k(k) {}
+ };
+
+ struct A : public virtual K {
+ int a;
+ constexpr A(int a) : a(a), K(12) {}
+ };
+
+ struct B : public virtual A {
+ constexpr B() : A(100), K(200) {}
+ constexpr B(int) : K(200), A(100) {}
+ };
+
+ constexpr B b{};
+ static_assert(b.a == 100);
+ static_assert(b.k == 200);
+
+ constexpr B b2{-1};
+ static_assert(b2.a == 100);
+ static_assert(b2.k == 200);
+
+ constexpr A a{13};
+ static_assert(a.a == 13);
+ static_assert(a.k == 12);
----------------
efriedma-quic wrote:
I think I'd like to also see tests for constructors and destructors along the
lines of:
```
struct A { constexpr A(int* p, int x) { *p += x; } };
struct B : virtual A { constexpr B(int* p) : A(p , 1) {} };
struct C : virtual B { constexpr C(int* p) : B(p), A(p, 2) {} };
constexpr int f() { int x = 0; C c(&x); return x; }
static_assert(f() == 2);
```
https://github.com/llvm/llvm-project/pull/204289
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits