diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index db92acb4c..4033f65a7 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -458,7 +458,8 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri code << str[i++]; } code << '}'; - } + } else + --i; } else if (ch == '#' && previous == '\n') { code << ch; previous = ch; diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 68b2e2add..b4c05f0c6 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -383,6 +383,7 @@ private: ASSERT_EQUALS(" __asm123", preprocessor.removeComments(" __asm123", "3837.cpp")); ASSERT_EQUALS("\" __asm { ; } \"", preprocessor.removeComments("\" __asm { ; } \"", "3837.cpp")); + ASSERT_EQUALS("__asm__ volatile { \"\" }", preprocessor.removeComments("__asm__ volatile { \"\" }", "3837.cpp")); }