File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -5604,6 +5604,22 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
5604
5604
5605
5605
if (!emitFieldInitializer (NestedField, NestedFieldOffset, InitExpr))
5606
5606
return false ;
5607
+
5608
+ // Mark all chain links as initialized.
5609
+ unsigned InitFieldOffset = 0 ;
5610
+ for (const NamedDecl *ND : IFD->chain ().drop_back ()) {
5611
+ const auto *FD = cast<FieldDecl>(ND);
5612
+ const Record *FieldRecord = this ->P .getOrCreateRecord (FD->getParent ());
5613
+ assert (FieldRecord);
5614
+ NestedField = FieldRecord->getField (FD);
5615
+ InitFieldOffset += NestedField->Offset ;
5616
+ assert (NestedField);
5617
+ if (!this ->emitGetPtrThisField (InitFieldOffset, InitExpr))
5618
+ return false ;
5619
+ if (!this ->emitFinishInitPop (InitExpr))
5620
+ return false ;
5621
+ }
5622
+
5607
5623
} else {
5608
5624
assert (Init->isDelegatingInitializer ());
5609
5625
if (!this ->emitThis (InitExpr))
Original file line number Diff line number Diff line change @@ -463,4 +463,26 @@ namespace MoveAssign {
463
463
}
464
464
static_assert (f()== 12 );
465
465
}
466
+
467
+ namespace IFD {
468
+ template <class T >
469
+ struct Optional {
470
+ struct {
471
+ union {
472
+ char null_state;
473
+ T val;
474
+ };
475
+ };
476
+ constexpr Optional () : null_state(){}
477
+ };
478
+
479
+ constexpr bool test ()
480
+ {
481
+ Optional<int > opt{};
482
+ Optional<int > opt2{};
483
+ opt = opt2;
484
+ return true ;
485
+ }
486
+ static_assert (test());
487
+ }
466
488
#endif
You can’t perform that action at this time.
0 commit comments