mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-05 21:30:52 +00:00
Improved error message during preprocessor expansion. Closes #683
This commit is contained in:
parent
ec8c555816
commit
2cc8c94d63
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
|
7
src/test/kc/preprocessor-15.c
Normal file
7
src/test/kc/preprocessor-15.c
Normal 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user