Skip to content

Commit 9d10f4f

Browse files
authored
Ticket #10028: Properly simplify auto variables' initialization. (#3079)
1 parent fa30464 commit 9d10f4f

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7529,7 +7529,7 @@ Token * Tokenizer::initVar(Token * tok)
75297529
return tok;
75307530

75317531
tok = tok->next();
7532-
} else if (!tok->isStandardType() && tok->next()->str() != "*")
7532+
} else if (!tok->isStandardType() && tok->str() != "auto" && tok->next()->str() != "*")
75337533
return tok;
75347534

75357535
// goto variable name..

test/teststl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5013,6 +5013,9 @@ class TestStl : public TestFixture {
50135013
"}\n",
50145014
true);
50155015
ASSERT_EQUALS("", errout.str());
5016+
5017+
check("void foo() { int f = 0; auto g(f); g = g; }");
5018+
ASSERT_EQUALS("", errout.str());
50165019
}
50175020
};
50185021

0 commit comments

Comments
 (0)