Fixed #3837 (False positive: national locale inline asm comments are reported as unsupported)
This commit is contained in:
parent
4e1bef5535
commit
c65ac603e9
|
@ -446,6 +446,19 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
||||||
suppressionIDs.push_back(word);
|
suppressionIDs.push_back(word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if ((i==0 || std::isspace(str[i-1])) && str.compare(i,5,"__asm",0,5) == 0) {
|
||||||
|
while (i < str.size() && !std::isspace(str[i]))
|
||||||
|
code << str[i++];
|
||||||
|
while (i < str.size() && std::isspace(str[i]))
|
||||||
|
code << str[i++];
|
||||||
|
if (str[i] == '{') {
|
||||||
|
while (i < str.size() && str[i] != '}') {
|
||||||
|
if (str[i] == ';')
|
||||||
|
i = str.find("\n", i);
|
||||||
|
code << str[i++];
|
||||||
|
}
|
||||||
|
code << '}';
|
||||||
|
}
|
||||||
} else if (ch == '#' && previous == '\n') {
|
} else if (ch == '#' && previous == '\n') {
|
||||||
code << ch;
|
code << ch;
|
||||||
previous = ch;
|
previous = ch;
|
||||||
|
|
|
@ -126,8 +126,6 @@ public:
|
||||||
|
|
||||||
void handleUndef(std::list<std::string> &configurations) const;
|
void handleUndef(std::list<std::string> &configurations) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* report error
|
* report error
|
||||||
* @param fileName name of file that the error was found in
|
* @param fileName name of file that the error was found in
|
||||||
|
|
|
@ -72,6 +72,9 @@ private:
|
||||||
// reading utf-16 file
|
// reading utf-16 file
|
||||||
TEST_CASE(utf16);
|
TEST_CASE(utf16);
|
||||||
|
|
||||||
|
// remove comments
|
||||||
|
TEST_CASE(removeComments);
|
||||||
|
|
||||||
// The bug that started the whole work with the new preprocessor
|
// The bug that started the whole work with the new preprocessor
|
||||||
TEST_CASE(Bug2190219);
|
TEST_CASE(Bug2190219);
|
||||||
|
|
||||||
|
@ -365,6 +368,24 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void removeComments() {
|
||||||
|
Settings settings;
|
||||||
|
Preprocessor preprocessor(&settings, this);
|
||||||
|
|
||||||
|
// #3837 - asm comments
|
||||||
|
const char code[] = "void test(void) {\n"
|
||||||
|
" __asm\n"
|
||||||
|
" {\n"
|
||||||
|
" ;---- тест\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(true, std::string::npos == preprocessor.removeComments(code, "3837.c").find("----"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS(" __asm123", preprocessor.removeComments(" __asm123", "3837.cpp"));
|
||||||
|
ASSERT_EQUALS("\" __asm { ; } \"", preprocessor.removeComments("\" __asm { ; } \"", "3837.cpp"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Bug2190219() {
|
void Bug2190219() {
|
||||||
const char filedata[] = "int main()\n"
|
const char filedata[] = "int main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue