forked from OSchip/llvm-project
[mlir] Fix emitting an error at EOF
Emitting at error at EOF will emit the diagnostic past the end of the file. When emitting an error during parsing at EOF, emit it at the previous character. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D122295
This commit is contained in:
parent
88da78ddd0
commit
7c72f55ea8
|
@ -69,6 +69,12 @@ public:
|
||||||
|
|
||||||
/// Emit an error and return failure.
|
/// Emit an error and return failure.
|
||||||
InFlightDiagnostic emitError(const Twine &message = {}) {
|
InFlightDiagnostic emitError(const Twine &message = {}) {
|
||||||
|
// If the error is to be emitted at EOF, move it back one character.
|
||||||
|
if (state.curToken.is(Token::eof)) {
|
||||||
|
return emitError(
|
||||||
|
SMLoc::getFromPointer(state.curToken.getLoc().getPointer() - 1),
|
||||||
|
message);
|
||||||
|
}
|
||||||
return emitError(state.curToken.getLoc(), message);
|
return emitError(state.curToken.getLoc(), message);
|
||||||
}
|
}
|
||||||
InFlightDiagnostic emitError(SMLoc loc, const Twine &message = {});
|
InFlightDiagnostic emitError(SMLoc loc, const Twine &message = {});
|
||||||
|
|
|
@ -680,7 +680,7 @@ func @calls(%arg0: i32) {
|
||||||
%z = "casdasda"(%x) : (ppop32) -> i32
|
%z = "casdasda"(%x) : (ppop32) -> i32
|
||||||
}
|
}
|
||||||
// -----
|
// -----
|
||||||
// expected-error@+2 {{expected SSA operand}}
|
// expected-error@+1 {{expected SSA operand}}
|
||||||
func@n(){^b(
|
func@n(){^b(
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
|
@ -882,7 +882,7 @@ func @type_alias_unknown(!unknown_alias) -> () { // expected-error {{undefined s
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
!missing_type_alias = type // expected-error@+2 {{expected non-function type}}
|
!missing_type_alias = type // expected-error@+1 {{expected non-function type}}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue