@@ -457,7 +457,8 @@ class PatternMatchEmission {
457
457
void emitDestructiveCaseBlocks ();
458
458
459
459
JumpDest getSharedCaseBlockDest (CaseStmt *caseStmt);
460
- void emitSharedCaseBlocks (llvm::function_ref<void (CaseStmt *)> bodyEmitter);
460
+ void emitSharedCaseBlocks (ValueOwnership ownership,
461
+ llvm::function_ref<void (CaseStmt *)> bodyEmitter);
461
462
462
463
void emitCaseBody (CaseStmt *caseBlock);
463
464
@@ -2899,7 +2900,21 @@ emitAddressOnlyInitialization(VarDecl *dest, SILValue value) {
2899
2900
2900
2901
// / Emit all the shared case statements.
2901
2902
void PatternMatchEmission::emitSharedCaseBlocks (
2903
+ ValueOwnership ownership,
2902
2904
llvm::function_ref<void (CaseStmt *)> bodyEmitter) {
2905
+ if (ownership >= ValueOwnership::Shared
2906
+ && !SharedCases.empty ()) {
2907
+ SGF.SGM .diagnose (SharedCases.front ().first ,
2908
+ diag::noncopyable_shared_case_block_unimplemented);
2909
+
2910
+ for (auto &entry : SharedCases) {
2911
+ SILBasicBlock *caseBB = entry.second .first ;
2912
+ SGF.B .setInsertionPoint (caseBB);
2913
+ SGF.B .createUnreachable (entry.first );
2914
+ }
2915
+
2916
+ return ;
2917
+ }
2903
2918
for (auto &entry : SharedCases) {
2904
2919
CaseStmt *caseBlock = entry.first ;
2905
2920
SILBasicBlock *caseBB = entry.second .first ;
@@ -3742,7 +3757,7 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
3742
3757
}
3743
3758
3744
3759
// Then emit the case blocks shared by multiple pattern cases.
3745
- emission.emitSharedCaseBlocks (
3760
+ emission.emitSharedCaseBlocks (ownership,
3746
3761
[&](CaseStmt *caseStmt) { emission.emitCaseBody (caseStmt); });
3747
3762
3748
3763
// Bookkeeping.
@@ -4015,7 +4030,8 @@ void SILGenFunction::emitCatchDispatch(DoCatchStmt *S, ManagedValue exn,
4015
4030
stmtScope.pop ();
4016
4031
4017
4032
// Then emit the case blocks shared by multiple pattern cases.
4018
- emission.emitSharedCaseBlocks ([&](CaseStmt *caseStmt) {
4033
+ emission.emitSharedCaseBlocks (ValueOwnership::Default,
4034
+ [&](CaseStmt *caseStmt) {
4019
4035
emitStmt (caseStmt->getBody ());
4020
4036
4021
4037
// If we fell out of the catch clause, branch to the fallthrough dest.
0 commit comments