Skip to content
Open
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
5 changes: 2 additions & 3 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3015,7 +3015,6 @@ bool Tokenizer::simplifyUsing()
Token::Match(tok->linkAt(2), "] ] = ::| %name%")))))
continue;

const std::string& name = tok->strAt(1);
const Token *nameToken = tok->next();
std::string scope = currentScope->fullName;
Token *usingStart = tok;
Expand Down Expand Up @@ -3064,7 +3063,7 @@ bool Tokenizer::simplifyUsing()
if (!hasName) {
std::string newName;
if (structEnd->strAt(2) == ";")
newName = name;
newName = nameToken->str();
else
newName = "Unnamed" + std::to_string(mUnnamedCount++);
TokenList::copyTokens(structEnd->next(), tok, start);
Expand Down Expand Up @@ -3211,7 +3210,7 @@ bool Tokenizer::simplifyUsing()
if (!isTypedefInfoAdded && Token::Match(tok1, "%name% (")) {
isTypedefInfoAdded = true;
TypedefInfo usingInfo;
usingInfo.name = name;
usingInfo.name = nameToken->str();
usingInfo.filename = list.file(nameToken);
usingInfo.lineNumber = nameToken->linenr();
usingInfo.column = nameToken->column();
Expand Down
7 changes: 7 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing37);
TEST_CASE(simplifyUsing38);
TEST_CASE(simplifyUsing39);
TEST_CASE(simplifyUsing40);

TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
Expand Down Expand Up @@ -939,6 +940,12 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void simplifyUsing40() {
const char code[] = "using C = struct C { C() {} };";
const char expected[] = "struct C { C ( ) { } } ;";
ASSERT_EQUALS(expected, tok(code));
}

void simplifyUsing8970() {
const char code[] = "using V = std::vector<int>;\n"
"struct A {\n"
Expand Down
Loading