Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Fix issue #60: Whitespace between # and error or line causes bogus er… #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flint/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,13 @@ namespace flint {
// Skip ws
auto pc1 = pc + 1;
tokenLen = 1 + munchSpaces(pc1).size();
// define, include, pragma, or line
// The entire #line line is the token value
if (startsWith(pc1, "line")) {
t = TK_HASHLINE; tokenLen += distance(pc, find(pc1, input.end(), '\n'));
t = TK_HASHLINE; tokenLen += distance(pc1, find(pc1, input.end(), '\n'));
}
else if (startsWith(pc1, "error")) {
// The entire #error line is the token value
t = TK_ERROR; tokenLen += distance(pc, find(pc1, input.end(), '\n'));
t = TK_ERROR; tokenLen += distance(pc1, find(pc1, input.end(), '\n'));
ENFORCE(tokenLen > 0, "Unterminated #error message");
}
else if (startsWith(pc1, "include")) {
Expand Down
6 changes: 6 additions & 0 deletions flint/tests/Error.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef ERROR_HPP
#define ERROR_HPP
#if abcdefg
# error Gadzooks.
#endif
#endif // ERROR_HPP
6 changes: 6 additions & 0 deletions flint/tests/Line.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef LINE_HPP
#define LINE_HPP
#if abcdefg
# line 12345678
#endif
#endif // LINE_HPP
4 changes: 2 additions & 2 deletions flint/tests/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
[Error ] Throw.cpp:10: Heap-allocated exception: throw new (MyException)(); This is usually a mistake in c++.
[Error ] Throw.cpp:12: Heap-allocated exception: throw new MyException(); This is usually a mistake in c++.

Lint Summary: 12 files
Lint Summary: 14 files
Errors: 23 Warnings: 29 Advice: 1

Estimated Lines of Code: 292
Estimated Lines of Code: 306