From 2d232dcaac6c9774728a702e466401562d1180a7 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 11 Nov 2023 10:09:08 +0100 Subject: [PATCH] Fix varid0 with rvalue reference typedef (#5649) --- lib/tokenize.cpp | 4 ++-- test/testsimplifytypedef.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3272939e6..9a44f6cd7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -656,7 +656,7 @@ namespace { } } - for (Token* type = start; Token::Match(type, "%name%|*|&"); type = type->next()) { + for (Token* type = start; Token::Match(type, "%name%|*|&|&&"); type = type->next()) { if (type != start && Token::Match(type, "%name% ;") && !type->isStandardType()) { mRangeType.first = start; mRangeType.second = type; @@ -892,7 +892,7 @@ namespace { // Unsplit variable declarations if (tok4 && tok4->isSplittedVarDeclEq() && - ((tok4->isCpp() && Token::Match(tok4->tokAt(-2), "& %name% ;")) || Token::Match(tok4->previous(), "] ; %name% = {"))) { + ((tok4->isCpp() && Token::Match(tok4->tokAt(-2), "&|&& %name% ;")) || Token::Match(tok4->previous(), "] ; %name% = {"))) { tok4->deleteNext(); tok4->deleteThis(); } diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 1e5570e6f..89a38f394 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -2517,7 +2517,7 @@ private: void simplifyTypedef109() { const char code[] = "typedef int&& rref;\n" "rref var = 0;"; - const char expected[] = "int && var ; var = 0 ;"; + const char expected[] = "int && var = 0 ;"; ASSERT_EQUALS(expected, tok(code)); ASSERT_EQUALS("", errout.str()); }