1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-07-01 22:29:45 +00:00

Improved error message during preprocessor expansion. Closes #683

This commit is contained in:
jespergravgaard 2021-07-29 19:00:48 +02:00
parent ec8c555816
commit 2cc8c94d63
3 changed files with 13 additions and 1 deletions

View File

@ -98,7 +98,7 @@ public class CParser {
int charPositionInLine,
String msg,
RecognitionException e) {
final CommonToken offendingToken = (CommonToken) offendingSymbol;
final Token offendingToken = (Token) offendingSymbol;
StatementSource source = new StatementSource(offendingToken.getInputStream().getSourceName(), line, charPositionInLine, null, -1, -1);
throw new CompileError("Error parsing file: " + msg, source);
}

View File

@ -929,6 +929,11 @@ public class TestProgramsFast extends TestPrograms {
compileAndCompare("cstyle-decl-function.c");
}
@Test
public void testPreprocessor15() throws IOException {
assertError("preprocessor-15.c", "Error parsing file: extraneous input 'X' ");
}
@Test
public void testPreprocessor14() throws IOException {
compileAndCompare("preprocessor-14.c");

View File

@ -0,0 +1,7 @@
// Demonstrates a problem with the preprocessor where the syntax error in the number results in an exception instead of a readable error
#define POKE(X,Y) (*(unsigned char*)(X))=Y
void main() {
POKE(0x123X,1);
}