forked from qt-creator/qt-creator
C++: Handle C++ style comments in macro expansion
Notice that a similar problem still exists for which we need to fix the lexer when there's a C style commend which ends with a backslash-newline. Task-number: QTCREATORBUG-7713 Change-Id: I0f6d561703984f917fa5ed29de020ad0bdc5aaf0 Reviewed-by: David Schulz <david.schulz@nokia.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -1181,6 +1181,42 @@ void tst_Preprocessor::comments_within_data()
|
||||
"# 10 \"<stdin>\"\n"
|
||||
"x = 10\n";
|
||||
QTest::newRow("case 4") << original << expected;
|
||||
|
||||
original = "#define FOO(x, y) { (void)x; (void)y; }\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
" FOO(10,\n"
|
||||
" //comment\n"
|
||||
" 12\n"
|
||||
"}\n";
|
||||
expected =
|
||||
"# 1 \"<stdin>\"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
"# expansion begin 57,3 ~4 4:7 ~4 6:7 7:0 ~2\n"
|
||||
"{ (void)10; (void)12}; }\n"
|
||||
"# expansion end\n"
|
||||
"# 8 \"<stdin>\"\n";
|
||||
QTest::newRow("case 5") << original << expected;
|
||||
|
||||
original = "#define FOO(x, y) { (void)x; (void)y; }\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
" FOO(10,\n"
|
||||
" //tricky*/comment\n"
|
||||
" 12\n"
|
||||
"}\n";
|
||||
expected =
|
||||
"# 1 \"<stdin>\"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
"# expansion begin 57,3 ~4 4:7 ~4 6:7 7:0 ~2\n"
|
||||
"{ (void)10; (void)12}; }\n"
|
||||
"# expansion end\n"
|
||||
"# 8 \"<stdin>\"\n";
|
||||
QTest::newRow("case 6") << original << expected;
|
||||
}
|
||||
|
||||
void tst_Preprocessor::comments_within2()
|
||||
@@ -1298,6 +1334,43 @@ void tst_Preprocessor::comments_within2_data()
|
||||
"*/\n"
|
||||
"x = 10\n";
|
||||
QTest::newRow("case 4") << original << expected;
|
||||
|
||||
|
||||
original = "#define FOO(x, y) { (void)x; (void)y; }\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
" FOO(10,\n"
|
||||
" //comment\n"
|
||||
" 12\n"
|
||||
"}\n";
|
||||
expected =
|
||||
"# 1 \"<stdin>\"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
"# expansion begin 57,3 ~4 4:7 ~5 6:7 7:0 ~2\n"
|
||||
"{ (void)10; (void)/*comment*/ 12}; }\n"
|
||||
"# expansion end\n"
|
||||
"# 8 \"<stdin>\"\n";
|
||||
QTest::newRow("case 5") << original << expected;
|
||||
|
||||
original = "#define FOO(x, y) { (void)x; (void)y; }\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
" FOO(10,\n"
|
||||
" //tricky*/comment\n"
|
||||
" 12\n"
|
||||
"}\n";
|
||||
expected =
|
||||
"# 1 \"<stdin>\"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"void foo() {\n"
|
||||
"# expansion begin 57,3 ~4 4:7 ~5 6:7 7:0 ~2\n"
|
||||
"{ (void)10; (void)/*tricky*|comment*/ 12}; }\n"
|
||||
"# expansion end\n"
|
||||
"# 8 \"<stdin>\"\n";
|
||||
QTest::newRow("case 6") << original << expected;
|
||||
}
|
||||
|
||||
void tst_Preprocessor::multiline_strings()
|
||||
|
Reference in New Issue
Block a user