This commit is contained in:
parent
a336048d14
commit
b2b0962067
|
@ -10169,11 +10169,14 @@ void Tokenizer::simplifyNamespaceAliases()
|
||||||
int scope = 0;
|
int scope = 0;
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
|
bool isPrev{};
|
||||||
if (tok->str() == "{")
|
if (tok->str() == "{")
|
||||||
scope++;
|
scope++;
|
||||||
else if (tok->str() == "}")
|
else if (tok->str() == "}")
|
||||||
scope--;
|
scope--;
|
||||||
else if (Token::Match(tok, "namespace %name% =")) {
|
else if (Token::Match(tok, "namespace %name% =") || (isPrev = Token::Match(tok->previous(), "namespace %name% ="))) {
|
||||||
|
if (isPrev)
|
||||||
|
tok = tok->previous();
|
||||||
const std::string name(tok->next()->str());
|
const std::string name(tok->next()->str());
|
||||||
Token * tokNameStart = tok->tokAt(3);
|
Token * tokNameStart = tok->tokAt(3);
|
||||||
Token * tokNameEnd = tokNameStart;
|
Token * tokNameEnd = tokNameStart;
|
||||||
|
|
|
@ -1455,6 +1455,9 @@ private:
|
||||||
"}"
|
"}"
|
||||||
"namespace AB = A::B;" //duplicate declaration
|
"namespace AB = A::B;" //duplicate declaration
|
||||||
"}"));
|
"}"));
|
||||||
|
ASSERT_EQUALS(";",
|
||||||
|
tok("namespace p = boost::python;\n"
|
||||||
|
"namespace np = boost::numpy;\n"));
|
||||||
|
|
||||||
// redeclared nested namespace aliases
|
// redeclared nested namespace aliases
|
||||||
TODO_ASSERT_EQUALS("namespace A { namespace B { void foo ( ) { bar ( A :: B :: ab ( ) ) ; { baz ( A :: a ( ) ) ; } bar ( A :: B :: ab ( ) ) ; } } }",
|
TODO_ASSERT_EQUALS("namespace A { namespace B { void foo ( ) { bar ( A :: B :: ab ( ) ) ; { baz ( A :: a ( ) ) ; } bar ( A :: B :: ab ( ) ) ; } } }",
|
||||||
|
|
Loading…
Reference in New Issue