Merge pull request #833 from simartin/ticket_7541

Ticket #7541: Properly keep track of namespace definition end markers
This commit is contained in:
orbitcowboy 2016-10-01 21:08:00 +02:00 committed by GitHub
commit f00636c0d3
2 changed files with 14 additions and 0 deletions

View File

@ -1067,6 +1067,7 @@ void Tokenizer::simplifyTypedef()
if (classLevel < spaceInfo.size() &&
spaceInfo[classLevel].isNamespace &&
spaceInfo[classLevel].className == tok2->previous()->str()) {
spaceInfo[classLevel].classEnd = tok2->link();
++classLevel;
pattern.clear();
for (std::size_t i = classLevel; i < spaceInfo.size(); ++i)

View File

@ -151,6 +151,7 @@ private:
TEST_CASE(simplifyTypedef116); // ticket #5624
TEST_CASE(simplifyTypedef117); // ticket #6507
TEST_CASE(simplifyTypedef118); // ticket #5749
TEST_CASE(simplifyTypedef119); // ticket #7541
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -2420,6 +2421,18 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef119() { // #7541
const char code[] = "namespace Baz {\n"
" typedef char* T1;\n"
" typedef T1 XX;\n"
"}\n"
"namespace Baz { }\n"
"enum Bar { XX = 1 };";
const char exp [] = "enum Bar { XX = 1 } ;";
ASSERT_EQUALS(exp, tok(code, false));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"