Fixed #5169 (Preprocessor::removeComments : Bad handling of __asm)

This commit is contained in:
Daniel Marjamäki 2014-01-01 12:44:59 +01:00
parent 5d31385161
commit cd65d8e54f
2 changed files with 5 additions and 1 deletions

View File

@ -584,7 +584,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
} }
} }
} else if ((i==0 || std::isspace(str[i-1])) && str.compare(i,5,"__asm",0,5) == 0) { } 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])) while (i < str.size() && (std::isalpha(str[i]) || str[i]=='_'))
code << str[i++]; code << str[i++];
while (i < str.size() && std::isspace(str[i])) while (i < str.size() && std::isspace(str[i]))
code << str[i++]; code << str[i++];

View File

@ -414,6 +414,10 @@ private:
// #4873 // #4873
ASSERT_EQUALS("__asm { }", preprocessor.removeComments("__asm { /* This is a comment */ }", "4873.cpp")); ASSERT_EQUALS("__asm { }", preprocessor.removeComments("__asm { /* This is a comment */ }", "4873.cpp"));
// #5169
ASSERT_EQUALS("#define A(B) __asm__(\"int $3\"); int wait=1;\n",
preprocessor.removeComments("#define A(B) __asm__(\"int $3\"); /**/ int wait=1;\n", "5169.c"));
} }