diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index cef3766a8..55d81bc68 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -904,6 +904,25 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg, std::string line; while (getline(istr, line)) { + if (line == "#pragma asm") + { + ret << "\n"; + bool found_end = false; + while (getline(istr, line)) + { + ret << "\n"; + if (line == "#pragma endasm") + { + found_end = true; + break; + } + } + if (!found_end) + break; + continue; + } + + std::string def = getdef(line, true); std::string ndef = getdef(line, false); diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 68734a09f..880b59961 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -133,6 +133,7 @@ private: TEST_CASE(stringify4); TEST_CASE(ifdefwithfile); TEST_CASE(pragma); + TEST_CASE(pragma_asm); TEST_CASE(endifsemicolon); TEST_CASE(missing_doublequote); @@ -1037,6 +1038,24 @@ private: ASSERT_EQUALS("\nvoid f()\n{\n}\n", actual[""]); } + void pragma_asm() + { + const char filedata[] = "#pragma asm\n" + " mov r1, 11\n" + "#pragma endasm\n" + "aaa"; + + // Preprocess => actual result.. + std::istringstream istr(filedata); + std::map actual; + Preprocessor preprocessor; + preprocessor.preprocess(istr, actual, "file.c"); + + // Compare results.. + ASSERT_EQUALS(1, static_cast(actual.size())); + ASSERT_EQUALS("\n\n\naaa\n", actual[""]); + } + void endifsemicolon() { const char filedata[] = "void f()\n"