File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,14 @@ bool ByteCodeStmtGen<Emitter>::visitFunc(const FunctionDecl *F) {
198198 return false ;
199199 if (!this ->emitInitPtrPop (InitExpr))
200200 return false ;
201+ } else {
202+ assert (Init->isDelegatingInitializer ());
203+ if (!this ->emitThis (InitExpr))
204+ return false ;
205+ if (!this ->visitInitializer (Init->getInit ()))
206+ return false ;
207+ if (!this ->emitPopPtr (InitExpr))
208+ return false ;
201209 }
202210 }
203211 }
Original file line number Diff line number Diff line change @@ -1066,3 +1066,26 @@ namespace ParenInit {
10661066 constexpr B b (A(1 ),2);
10671067}
10681068#endif
1069+
1070+ namespace DelegatingConstructors {
1071+ struct S {
1072+ int a;
1073+ constexpr S () : S(10 ) {}
1074+ constexpr S (int a) : a(a) {}
1075+ };
1076+ constexpr S s = {};
1077+ static_assert (s.a == 10 , " " );
1078+
1079+ struct B {
1080+ int a;
1081+ int b;
1082+
1083+ constexpr B (int a) : a(a), b(a + 2 ) {}
1084+ };
1085+ struct A : B {
1086+ constexpr A () : B(10 ) {};
1087+ };
1088+ constexpr A d4 = {};
1089+ static_assert (d4.a == 10 , " " );
1090+ static_assert (d4.b == 12 , " " );
1091+ }
You can’t perform that action at this time.
0 commit comments