diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 4b26f814cbbe9..810a87a6cc768 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -4366,12 +4366,12 @@ def CIR_TryOp : CIR_Op<"try",[ let arguments = (ins UnitAttr:$synthetic, UnitAttr:$cleanup, - CIR_TryHandlerArrayAttr:$handler_types + DefaultValuedAttr:$handler_types ); let regions = (region AnyRegion:$try_region, - VariadicRegion>:$handler_regions + VariadicRegion:$handler_regions ); let assemblyFormat = [{ diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 0712de2d2f182..4756c75896e0f 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -2977,8 +2977,11 @@ static mlir::ParseResult parseTryHandlerRegions( return failure(); } - if (!currRegion.empty() && !(currRegion.back().mightHaveTerminator() && - currRegion.back().getTerminator())) + if (currRegion.empty()) + return parser.emitError(regionLoc, "handler region shall not be empty"); + + if (!(currRegion.back().mightHaveTerminator() && + currRegion.back().getTerminator())) return parser.emitError( regionLoc, "blocks are expected to be explicitly terminated"); diff --git a/clang/test/CIR/IR/invalid-try-catch.cir b/clang/test/CIR/IR/invalid-try-catch.cir index 04a4d2543b8e1..94df4b63ed629 100644 --- a/clang/test/CIR/IR/invalid-try-catch.cir +++ b/clang/test/CIR/IR/invalid-try-catch.cir @@ -40,10 +40,11 @@ module { cir.func dso_local @invalid_catch_empty_block() { cir.scope { - // expected-error @below {{'cir.try' op region #1 ('handler_regions') failed to verify constraint: region with at least 1 blocks}} cir.try { cir.yield - } catch all { + } + // expected-error @below {{'cir.try' handler region shall not be empty}} + catch all { } } cir.return