Skip to content

Commit a889246

Browse files
committed
Add error message for using unwind with catch all
1 parent 523b1ee commit a889246

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,10 @@ parseCatchRegions(mlir::OpAsmParser &parser,
29872987
}
29882988

29892989
if (parser.parseOptionalKeyword("unwind").succeeded()) {
2990+
if (hasCatchAll)
2991+
return parser.emitError(parser.getCurrentLocation(),
2992+
"unwind can't be used with catch all");
2993+
29902994
catcherAttrs.push_back(cir::UnwindAttr::get(parser.getContext()));
29912995
if (parseCheckedCatcherRegion().failed())
29922996
return mlir::failure();

clang/test/CIR/IR/invalid-try-catch.cir

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cir.func dso_local @invalid_catch_all_with_type_info() {
122122
cir.scope {
123123
cir.try {
124124
cir.yield
125-
}
125+
}
126126
// expected-error @below {{op 'cir.try' catch all dosen't need RTTI info attribute}}
127127
catch [all] {
128128
cir.yield
@@ -133,3 +133,24 @@ cir.func dso_local @invalid_catch_all_with_type_info() {
133133

134134
}
135135

136+
// -----
137+
138+
module {
139+
140+
cir.func dso_local @invalid_unwind_with_catch_all() {
141+
cir.scope {
142+
cir.try {
143+
cir.yield
144+
}
145+
catch all {
146+
cir.yield
147+
}
148+
// expected-error @below {{op 'cir.try' unwind can't be used with catch all}}
149+
unwind {
150+
151+
}
152+
}
153+
cir.return
154+
}
155+
156+
}

0 commit comments

Comments
 (0)