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"))
+ if (getToken().is(Token::l_paren))
+ if (parseOptionalBlockArgList(block))
return failure();
- }
if (parseToken(Token::colon, "expected ':' after block name"))
return failure();
return blockAndLoc.block;
}
-/// Parse a (possibly empty) list of SSA operands with types as block arguments.
+/// Parse a (possibly empty) list of SSA operands with types as block arguments
+/// enclosed in parentheses.
///
-/// ssa-id-and-type-list ::= ssa-id-and-type (`,` ssa-id-and-type)*
+/// value-id-and-type-list ::= value-id-and-type (`,` ssa-id-and-type)*
+/// block-arg-list ::= `(` value-id-and-type-list? `)`
///
ParseResult OperationParser::parseOptionalBlockArgList(Block *owner) {
if (getToken().is(Token::r_brace))
bool definingExistingArgs = owner->getNumArguments() != 0;
unsigned nextArgument = 0;
- return parseCommaSeparatedList([&]() -> ParseResult {
+ return parseCommaSeparatedList(Delimiter::Paren, [&]() -> ParseResult {
return parseSSADefOrUseAndType(
[&](SSAUseInfo useInfo, Type type) -> ParseResult {
BlockArgument arg;
// -----
func @block_no_rparen() {
-^bb42 (%bb42 : i32: // expected-error {{expected ')' to end argument list}}
+^bb42 (%bb42 : i32: // expected-error {{expected ')'}}
return
}
%y = arith.constant 1 : i32 // expected-error {{block with no terminator}}
}
+// -----
+
+func @no_block_arg_enclosing_parens() {
+^bb %x: i32 : // expected-error {{expected ':' after block name}}
+ return
+}
// -----