From 9d10f4f572b0059310e52150adb9f6f215a0025a Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sat, 23 Jan 2021 17:56:58 +0100 Subject: [PATCH] Ticket #10028: Properly simplify auto variables' initialization. (#3079) --- lib/tokenize.cpp | 2 +- test/teststl.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f6e3c5185..c611890f3 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7529,7 +7529,7 @@ Token * Tokenizer::initVar(Token * tok) return tok; tok = tok->next(); - } else if (!tok->isStandardType() && tok->next()->str() != "*") + } else if (!tok->isStandardType() && tok->str() != "auto" && tok->next()->str() != "*") return tok; // goto variable name.. diff --git a/test/teststl.cpp b/test/teststl.cpp index 84924d9e8..69316ef1a 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -5013,6 +5013,9 @@ private: "}\n", true); ASSERT_EQUALS("", errout.str()); + + check("void foo() { int f = 0; auto g(f); g = g; }"); + ASSERT_EQUALS("", errout.str()); } };