diff --git a/CHANGES.current b/CHANGES.current index d875740a5..515ad8f61 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.4 (in progress) =========================== +2015-01-08: olly + When reporting an error for a construct which hasn't been + terminated when the end of the file is reached, report it at the + start line rather than "EOF" as then tools like editors and IDEs + will take you to a generally more useful place for fixing the + problem. + 2015-01-08: olly Improve error message for extraneous '%}'. diff --git a/Examples/test-suite/errors/pp_missing_enddef.stderr b/Examples/test-suite/errors/pp_missing_enddef.stderr index bb4ea3c75..c461699e6 100644 --- a/Examples/test-suite/errors/pp_missing_enddef.stderr +++ b/Examples/test-suite/errors/pp_missing_enddef.stderr @@ -1 +1 @@ -pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3 +pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here diff --git a/Examples/test-suite/errors/pp_missing_endif.stderr b/Examples/test-suite/errors/pp_missing_endif.stderr index 0bbfad7f2..4db4021aa 100644 --- a/Examples/test-suite/errors/pp_missing_endif.stderr +++ b/Examples/test-suite/errors/pp_missing_endif.stderr @@ -1 +1 @@ -pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3 +pp_missing_endif.i:3: Error: Missing #endif for conditional starting here diff --git a/Examples/test-suite/errors/pp_missing_endoffile.i b/Examples/test-suite/errors/pp_missing_endoffile.i new file mode 100644 index 000000000..2074495a8 --- /dev/null +++ b/Examples/test-suite/errors/pp_missing_endoffile.i @@ -0,0 +1,7 @@ +%module xxx +/* %beginfile and %endoffile are internal directives inserted when %include is + * used. Users should never use them directly, but test coverage for this + * error message still seems useful to have. + */ +%includefile "dummy.i" %beginfile + diff --git a/Examples/test-suite/errors/pp_missing_endoffile.stderr b/Examples/test-suite/errors/pp_missing_endoffile.stderr new file mode 100644 index 000000000..7269f2e92 --- /dev/null +++ b/Examples/test-suite/errors/pp_missing_endoffile.stderr @@ -0,0 +1 @@ +pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here diff --git a/Examples/test-suite/errors/pp_missing_rblock.stderr b/Examples/test-suite/errors/pp_missing_rblock.stderr index 8f4a54c0a..f00457d73 100644 --- a/Examples/test-suite/errors/pp_missing_rblock.stderr +++ b/Examples/test-suite/errors/pp_missing_rblock.stderr @@ -1 +1 @@ -pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3 +pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block diff --git a/Examples/test-suite/errors/pp_unterm_char.stderr b/Examples/test-suite/errors/pp_unterm_char.stderr index 4386e933d..147e3859d 100644 --- a/Examples/test-suite/errors/pp_unterm_char.stderr +++ b/Examples/test-suite/errors/pp_unterm_char.stderr @@ -1 +1 @@ -pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4 +pp_unterm_char.i:4: Error: Unterminated character constant diff --git a/Examples/test-suite/errors/pp_unterm_comment.stderr b/Examples/test-suite/errors/pp_unterm_comment.stderr index 4ff34230c..ab1edac14 100644 --- a/Examples/test-suite/errors/pp_unterm_comment.stderr +++ b/Examples/test-suite/errors/pp_unterm_comment.stderr @@ -1 +1 @@ -pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3 +pp_unterm_comment.i:3: Error: Unterminated comment diff --git a/Examples/test-suite/errors/pp_unterm_string.stderr b/Examples/test-suite/errors/pp_unterm_string.stderr index 16b4034f3..14e110ebb 100644 --- a/Examples/test-suite/errors/pp_unterm_string.stderr +++ b/Examples/test-suite/errors/pp_unterm_string.stderr @@ -1 +1 @@ -pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4 +pp_unterm_string.i:4: Error: Unterminated string constant diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index b556bce27..8fd30f703 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1376,12 +1376,12 @@ String *Preprocessor_parse(String *s) { else if (c == '\"') { start_line = Getline(s); if (skip_tochar(s, '\"', chunk) < 0) { - Swig_error(Getfile(s), -1, "Unterminated string constant starting at line %d\n", start_line); + Swig_error(Getfile(s), start_line, "Unterminated string constant\n"); } } else if (c == '\'') { start_line = Getline(s); if (skip_tochar(s, '\'', chunk) < 0) { - Swig_error(Getfile(s), -1, "Unterminated character constant starting at line %d\n", start_line); + Swig_error(Getfile(s), start_line, "Unterminated character constant\n"); } } else if (c == '/') state = 30; /* Comment */ @@ -2008,21 +2008,21 @@ String *Preprocessor_parse(String *s) { } } while (level > 0) { - Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]); + Swig_error(Getfile(s), cond_lines[level - 1], "Missing #endif for conditional starting here\n"); level--; } if (state == 120) { - Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line); + Swig_error(Getfile(s), start_line, "Missing %%endoffile for file inclusion block starting here\n"); } if (state == 150) { Seek(value, 0, SEEK_SET); - Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value)); + Swig_error(Getfile(s), Getline(value), "Missing %%enddef for macro starting here\n", Getline(value)); } if ((state >= 105) && (state < 107)) { - Swig_error(Getfile(s), -1, "Unterminated %%{ ... %%} block starting on line %d\n", start_line); + Swig_error(Getfile(s), start_line, "Unterminated %%{ ... %%} block\n"); } if ((state >= 30) && (state < 40)) { - Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line); + Swig_error(Getfile(s), start_line, "Unterminated comment\n"); } copy_location(s, chunk);