diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1958,11 +1958,8 @@ return emitError(nameLoc, "redefinition of block '") << name << "'"; // If an argument list is present, parse it. - if (consumeIf(Token::l_paren)) { - if (parseOptionalBlockArgList(block) || - parseToken(Token::r_paren, "expected ')' to end argument list")) - return failure(); - } + if (parseOptionalBlockArgList(block)) + return failure(); if (parseToken(Token::colon, "expected ':' after block name")) return failure(); @@ -2038,9 +2035,10 @@ bool definingExistingArgs = owner->getNumArguments() != 0; unsigned nextArgument = 0; - return parseCommaSeparatedList([&]() -> ParseResult { - return parseSSADefOrUseAndType( - [&](SSAUseInfo useInfo, Type type) -> ParseResult { + return parseCommaSeparatedList( + Delimiter::OptionalParen, [&]() -> ParseResult { + return parseSSADefOrUseAndType([&](SSAUseInfo useInfo, + Type type) -> ParseResult { BlockArgument arg; // If we are defining existing arguments, ensure that the argument @@ -2071,7 +2069,7 @@ return addDefinition(useInfo, arg); }); - }); + }); } //===----------------------------------------------------------------------===// diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -136,7 +136,7 @@ // ----- func @block_no_rparen() { -^bb42 (%bb42 : i32: // expected-error {{expected ')' to end argument list}} +^bb42 (%bb42 : i32: // expected-error {{expected ')'}} return } diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -181,6 +181,12 @@ // CHECK: } } +// CHECK-LABEL: func @block_label_empty_list +func @block_label_empty_list() { +^bb0(): + return +} + // CHECK-LABEL: func @multiblock() { func @multiblock() { return // CHECK: return