forked from OSchip/llvm-project
Check for absence of delimiters when delimiters is None and fixed number of operands expected.
Ensure delimiters are absent where not expected. This is only checked in the case where operand count is known. This allows for the currently accepted case where there is a operand list with no delimiter and variable number of operands (which could be empty), followed by a delimited operand list. PiperOrigin-RevId: 212202064
This commit is contained in:
parent
d101fb937b
commit
cf9aba2b2b
|
@ -1785,7 +1785,20 @@ public:
|
|||
// Handle delimiters.
|
||||
switch (delimiter) {
|
||||
case Delimiter::None:
|
||||
break;
|
||||
// Don't check for the absence of a delimiter if the number of operands
|
||||
// is unknown (and hence the operand list could be empty).
|
||||
if (requiredOperandCount == -1)
|
||||
break;
|
||||
// Token already matches an identifier and so can't be a delimiter.
|
||||
if (parser.getToken().is(Token::percent_identifier))
|
||||
break;
|
||||
// Test against known delimiters.
|
||||
if (parser.getToken().is(Token::l_paren) ||
|
||||
parser.getToken().is(Token::l_square))
|
||||
return emitError(startLoc, "unexpected delimiter");
|
||||
return emitError(startLoc, "unable to parse '" +
|
||||
parser.getTokenSpelling() +
|
||||
"' as operand");
|
||||
case Delimiter::OptionalParen:
|
||||
if (parser.getToken().isNot(Token::l_paren))
|
||||
return false;
|
||||
|
|
|
@ -126,5 +126,20 @@ mlfunc @calls(%arg0 : i32) {
|
|||
|
||||
cfgfunc @cfgfunc_with_ops(f32) {
|
||||
bb0(%a : f32):
|
||||
%sf = addf(%a, %a) : f32 // expected-error {{custom op 'addf' expected 2 operands}}
|
||||
%sf = addf %a, %a, %a : f32 // expected-error {{custom op 'addf' expected 2 operands}}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
cfgfunc @cfgfunc_with_ops(f32) {
|
||||
bb0(%a : f32):
|
||||
%sf = addf(%a, %a) : f32 // expected-error {{unexpected delimiter}}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
cfgfunc @cfgfunc_with_ops(f32) {
|
||||
bb0(%a : f32):
|
||||
%sf = addf{%a, %a} : f32 // expected-error {{unable to parse '{' as operand}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue