Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@ bool Tokenizer::simplifyUsing()
}
if (tok == endOfTemplateDefinition) {
inTemplateDefinition = false;
endOfTemplateDefinition = nullptr;
continue;
}
}
Expand Down Expand Up @@ -2127,7 +2128,6 @@ bool Tokenizer::simplifyUsing()
str += " ;";
std::list<const Token *> callstack(1, usingStart);
mErrorLogger->reportErr(ErrorLogger::ErrorMessage(callstack, &list, Severity::debug, "debug",

"Failed to parse \'" + str + "\'. The checking continues anyway.", false));
}
}
Expand All @@ -2148,7 +2148,7 @@ bool Tokenizer::simplifyUsing()
if (usingEnd->next())
Token::eraseTokens(usingStart->previous(), usingEnd->next());
else {
Token::eraseTokens(usingStart, usingEnd);
Token::eraseTokens(usingStart->previous(), usingEnd);
usingEnd->deleteThis();
}
} else {
Expand Down
10 changes: 10 additions & 0 deletions test/testpostfixoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ class TestPostfixOperator : public TestFixture {
"}");
ASSERT_EQUALS("", errout.str());

// #9042
check("template <class T>\n"
"class c {\n"
" int i = 0;\n"
" c() { i--; }\n"
"};\n"
"template <class T>\n"
"class s {};\n"
"using BOOL = char;");
ASSERT_EQUALS("", errout.str());
}

void testfor() {
Expand Down
22 changes: 22 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing8971);
TEST_CASE(simplifyUsing8976);
TEST_CASE(simplifyUsing9040);
TEST_CASE(simplifyUsing9042);
}

std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) {
Expand Down Expand Up @@ -474,6 +475,27 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS(exp, tok(code, true, Settings::Win64));
}

void simplifyUsing9042() {
const char code[] = "template <class T>\n"
"class c {\n"
" int i = 0;\n"
" c() { i--; }\n"
"};\n"
"template <class T>\n"
"class s {};\n"
"using BOOL = char;";

const char exp[] = "template < class T > "
"class c { "
"int i ; i = 0 ; "
"c ( ) { i -- ; } "
"} ; "
"template < class T > "
"class s { } ;";

ASSERT_EQUALS(exp, tok(code, true, Settings::Win64));
}

};

REGISTER_TEST(TestSimplifyUsing)