Fixed #582 (Preprocessor: Remove assembler code inside pragmas)

This commit is contained in:
Daniel Marjamäki 2009-08-10 20:07:55 +02:00
parent 93604dd344
commit 045b73c7ec
2 changed files with 38 additions and 0 deletions

View File

@ -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);

View File

@ -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<std::string, std::string> actual;
Preprocessor preprocessor;
preprocessor.preprocess(istr, actual, "file.c");
// Compare results..
ASSERT_EQUALS(1, static_cast<unsigned int>(actual.size()));
ASSERT_EQUALS("\n\n\naaa\n", actual[""]);
}
void endifsemicolon()
{
const char filedata[] = "void f()\n"