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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Gerhard Zlabinger
Gerik Rhoden
Gianfranco Costamagna
Gianluca Scacco
Gilmar Santos Jr
Gleydson Soares
Goncalo Mao-Cheia
Goran Džaferi
Expand Down
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 @@ -98,6 +98,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing10335);
TEST_CASE(simplifyUsing10720);
TEST_CASE(simplifyUsing13873); // function declaration
TEST_CASE(simplifyUsing14877);

TEST_CASE(scopeInfo1);
TEST_CASE(scopeInfo2);
Expand Down Expand Up @@ -1667,6 +1668,12 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS("namespace NS1 { void * f ( ) ; }", tok(code3));
}

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

void scopeInfo1() {
const char code[] = "struct A {\n"
" enum class Mode { UNKNOWN, ENABLED, NONE, };\n"
Expand Down