Skip to content

Commit cbda68a

Browse files
authored
Update SemaLambda.cpp
1 parent 34807aa commit cbda68a

File tree

1 file changed

+22
-40
lines changed

1 file changed

+22
-40
lines changed

clang/lib/Sema/SemaLambda.cpp

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,47 +1196,29 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
11961196
// for e.g., [n{0}] { }; <-- if no <initializer_list> is included.
11971197
// FIXME: we should create the init capture variable and mark it invalid
11981198
// in this case.
1199-
// Check if the initializer type is invalid or unusable
1200-
if (C->InitCaptureType.get().isNull() && !C->Init.isUsable()) {
1201-
Diag(C->Loc, diag::err_invalid_lambda_capture_initializer_type)
1202-
<< C->Id; // Provide more context by including the capture name
1203-
continue;
1204-
}
1205-
1206-
// Check if there are unexpanded parameter packs
1207-
if (C->Init.get()->containsUnexpandedParameterPack() &&
1208-
!C->InitCaptureType.get()->getAs<PackExpansionType>()) {
1209-
Diag(C->Loc, diag::err_pack_expansion_mismatch)
1210-
<< C->Id; // Include the problematic capture for context
1211-
DiagnoseUnexpandedParameterPack(C->Init.get(), UPPC_Initializer);
1212-
}
1199+
if (C->InitCaptureType.get().isNull() && !C->Init.isUsable()) {
1200+
Diag(C->Loc, diag::err_invalid_lambda_capture_initializer_type); //
1201+
continue; //
1202+
}
12131203

1214-
// Determine the appropriate initialization style
1215-
unsigned InitStyle;
1216-
switch (C->InitKind) {
1217-
case LambdaCaptureInitKind::NoInit:
1218-
Diag(C->Loc, diag::err_unsupported_lambda_capture_no_init)
1219-
<< C->Id; // Mention the capture name causing the issue
1220-
llvm_unreachable("not an init-capture?");
1221-
1222-
case LambdaCaptureInitKind::CopyInit:
1223-
InitStyle = VarDecl::CInit;
1224-
Diag(C->Loc, diag::note_lambda_capture_copy_init)
1225-
<< C->Id; // Note about using copy initialization
1226-
break;
1227-
1228-
case LambdaCaptureInitKind::DirectInit:
1229-
InitStyle = VarDecl::CallInit;
1230-
Diag(C->Loc, diag::note_lambda_capture_direct_init)
1231-
<< C->Id; // Note about using direct initialization
1232-
break;
1233-
1234-
case LambdaCaptureInitKind::ListInit:
1235-
InitStyle = VarDecl::ListInit;
1236-
Diag(C->Loc, diag::note_lambda_capture_list_init)
1237-
<< C->Id; // Note about using list initialization
1238-
break;
1239-
}
1204+
if (C->Init.get()->containsUnexpandedParameterPack() &&
1205+
!C->InitCaptureType.get()->getAs<PackExpansionType>())
1206+
DiagnoseUnexpandedParameterPack(C->Init.get(), UPPC_Initializer);
1207+
1208+
unsigned InitStyle;
1209+
switch (C->InitKind) {
1210+
case LambdaCaptureInitKind::NoInit:
1211+
llvm_unreachable("not an init-capture?");
1212+
case LambdaCaptureInitKind::CopyInit:
1213+
InitStyle = VarDecl::CInit;
1214+
break;
1215+
case LambdaCaptureInitKind::DirectInit:
1216+
InitStyle = VarDecl::CallInit;
1217+
break;
1218+
case LambdaCaptureInitKind::ListInit:
1219+
InitStyle = VarDecl::ListInit;
1220+
break;
1221+
}
12401222
Var = createLambdaInitCaptureVarDecl(C->Loc, C->InitCaptureType.get(),
12411223
C->EllipsisLoc, C->Id, InitStyle,
12421224
C->Init.get(), Method);

0 commit comments

Comments
 (0)