Skip to content

Commit 5300dc2

Browse files
authored
Merge pull request #32534 from zoecarver/fix/cxx/constructor-return-stmt
2 parents a8d44bc + 096777e commit 5300dc2

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,11 +1272,7 @@ synthesizeStructDefaultConstructorBody(AbstractFunctionDecl *afd,
12721272
auto assign = new (ctx) AssignExpr(lhs, SourceLoc(), call, /*implicit*/ true);
12731273
assign->setType(emptyTuple);
12741274

1275-
auto result = TupleExpr::createEmpty(ctx, SourceLoc(), SourceLoc(),
1276-
/*Implicit=*/true);
1277-
result->setType(emptyTuple);
1278-
1279-
auto ret = new (ctx) ReturnStmt(SourceLoc(), result, /*Implicit=*/true);
1275+
auto ret = new (ctx) ReturnStmt(SourceLoc(), nullptr, /*Implicit=*/true);
12801276

12811277
// Create the function body.
12821278
auto body = BraceStmt::create(ctx, SourceLoc(), {assign, ret}, SourceLoc());
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct HasCustomCopyConst {
2+
HasCustomCopyConst(HasCustomCopyConst const&) { }
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module CXXTypes {
2+
header "cxx-types.h"
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -enable-cxx-interop -I %S/Inputs %s -emit-silgen | %FileCheck %s
2+
3+
import CXXTypes
4+
5+
// Just make sure we create the object and don't crash.
6+
// CHECK-LABEL: @$s4main4testyyF
7+
// CHECK: alloc_stack
8+
// CHECK: apply
9+
// CHECK: return %{{[0-9]+}} : $()
10+
public func test() {
11+
let c = HasCustomCopyConst()
12+
}

0 commit comments

Comments
 (0)