Fixed #4191 (wrong syntax error if 'error' substring of stringification)
This commit is contained in:
parent
2db1dbe2ce
commit
6ebfbf42e1
|
@ -353,8 +353,9 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
|||
writeError(filename, lineno, _errorLogger, "syntaxError", errmsg.str());
|
||||
}
|
||||
|
||||
if ((str.compare(i, 6, "#error") == 0 && (!_settings || _settings->userDefines.empty())) ||
|
||||
str.compare(i, 8, "#warning") == 0) {
|
||||
if ((str.compare(i, 7, "#error ") == 0 && (!_settings || _settings->userDefines.empty())) ||
|
||||
str.compare(i, 9, "#warning ") == 0) {
|
||||
|
||||
if (str.compare(i, 6, "#error") == 0)
|
||||
code << "#error";
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ private:
|
|||
// Just read the code into a string. Perform simple cleanup of the code
|
||||
TEST_CASE(readCode1);
|
||||
TEST_CASE(readCode2);
|
||||
TEST_CASE(readCode3);
|
||||
|
||||
// reading utf-16 file
|
||||
TEST_CASE(utf16);
|
||||
|
@ -300,6 +301,15 @@ private:
|
|||
ASSERT_EQUALS("\" \\\" /* abc */ \\n\"\n", codestr);
|
||||
}
|
||||
|
||||
void readCode3() {
|
||||
const char code[] = "func(#errorname)";
|
||||
Settings settings;
|
||||
Preprocessor preprocessor(&settings, this);
|
||||
std::istringstream istr(code);
|
||||
std::string codestr(preprocessor.read(istr,"test.c"));
|
||||
ASSERT_EQUALS("func(#errorname)", codestr);
|
||||
}
|
||||
|
||||
|
||||
void utf16() {
|
||||
Settings settings;
|
||||
|
|
Loading…
Reference in New Issue