forked from OSchip/llvm-project
Check that at least one constraint is parsed when parsing an IntegerSet.
PiperOrigin-RevId: 229248638
This commit is contained in:
parent
61ec6c0992
commit
6c1631b3f8
|
@ -3167,7 +3167,7 @@ IntegerSet AffineParser::parseIntegerSetConstraints(unsigned numDims,
|
|||
unsigned numSymbols) {
|
||||
if (parseToken(Token::l_paren,
|
||||
"expected '(' at start of integer set constraint list"))
|
||||
return IntegerSet();
|
||||
return IntegerSet::Null();
|
||||
|
||||
SmallVector<AffineExpr, 4> constraints;
|
||||
SmallVector<bool, 4> isEqs;
|
||||
|
@ -3185,8 +3185,15 @@ IntegerSet AffineParser::parseIntegerSetConstraints(unsigned numDims,
|
|||
// Parse a list of affine constraints (comma-separated) .
|
||||
// Grammar: affine-constraint-conjunct ::= `(` affine-constraint (`,`
|
||||
// affine-constraint)* `)
|
||||
auto constraintListLoc = getToken().getLoc();
|
||||
if (parseCommaSeparatedListUntil(Token::r_paren, parseElt, true))
|
||||
return IntegerSet();
|
||||
return IntegerSet::Null();
|
||||
|
||||
// Check that at least one constraint was parsed.
|
||||
if (constraints.empty()) {
|
||||
emitError(constraintListLoc, "expected a valid affine constraint");
|
||||
return IntegerSet::Null();
|
||||
}
|
||||
|
||||
// Parsed a valid integer set.
|
||||
return builder.getIntegerSet(numDims, numSymbols, constraints, isEqs);
|
||||
|
|
|
@ -882,3 +882,7 @@ func @invalid_tensor_literal() {
|
|||
func @invalid_tensor_literal() {
|
||||
// expected-error @+1 {{expected '[' or scalar constant inside tensor literal}}
|
||||
"fooi16"(){bar: sparse<tensor<2x2x2xi16>, [[1, 1, 0], [0, 1, 0], [0,, [[0, 0, 0]], [-2.0]>} : () -> ()
|
||||
|
||||
// -----
|
||||
|
||||
#set_without_constraints = (i, j) : () // expected-error {{expected a valid affine constraint}}
|
||||
|
|
Loading…
Reference in New Issue