File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -5836,6 +5836,8 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
5836
5836
return false ;
5837
5837
5838
5838
if (R->isUnion () && Ctor->isCopyOrMoveConstructor ()) {
5839
+ if (R->getNumFields () == 0 )
5840
+ return this ->emitRetVoid (Ctor);
5839
5841
// union copy and move ctors are special.
5840
5842
assert (cast<CompoundStmt>(Ctor->getBody ())->body_empty ());
5841
5843
if (!this ->emitThis (Ctor))
Original file line number Diff line number Diff line change @@ -600,6 +600,18 @@ namespace MoveOrAssignOp {
600
600
}
601
601
static_assert (foo());
602
602
}
603
+
604
+ namespace CopyEmptyUnion {
605
+ struct A {
606
+ union {}; // both-warning {{declaration does not declare anything}}
607
+ };
608
+ constexpr int foo () {
609
+ A a;
610
+ A a2 = a;
611
+ return 1 ;
612
+ }
613
+ static_assert (foo() == 1 );
614
+ }
603
615
#endif
604
616
605
617
namespace AddressComparison {
You can’t perform that action at this time.
0 commit comments