mirror of
https://gitlab.com/camelot/kickc.git
synced 2026-04-26 06:18:34 +00:00
Improved error message during preprocessor expansion. Closes #683
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user