JossWhittle / FlintPlusPlus

Flint++ is cross-platform, zero-dependency port of flint, a lint program for C++ developed and used at Facebook.
Boost Software License 1.0
266 stars 21 forks source link

Whitespace between # and "error" or "line" causes bogus errors to be reported #60

Open warmsocks opened 5 years ago

warmsocks commented 5 years ago

If a #error or #line preprocessor directive contains whitespace between the # and the word "error" or "line", the tokenizer breaks and bogus errors are reported.

Example 1: "# errror ..."

#ifndef ERROR_HPP
#define ERROR_HPP
#if abcdefg
#                    error Gadzooks.
#endif
#endif // ERROR_HPP

Results in this:

$ flint++ Error.hpp
[Error  ] Error.hpp:5: Unmatched #if/#endif.
[Error  ] Error.hpp:5: Include guard doesn't cover the entire file.

Lint Summary: 1 files
Errors: 2 Warnings: 0 Advice: 0

Estimated Lines of Code: 5

Example 2: "# line ..."

#ifndef LINE_HPP
#define LINE_HPP
#if abcdefg
#            line 12345678
#endif
#endif // LINE_HPP

Results in this:

$ flint++ Error.hpp
[Error  ] Line.hpp:5: Unmatched #if/#endif.
[Error  ] Line.hpp:5: Include guard doesn't cover the entire file.

Lint Summary: 1 files
Errors: 2 Warnings: 0 Advice: 0

Estimated Lines of Code: 5