diff --git a/lib/checkother.cpp b/lib/checkother.cpp index aedf2e33c..ea1343042 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -68,7 +68,7 @@ static bool isSameExpression(const Token *tok1, const Token *tok2, const std::se return true; if (tok1 == nullptr || tok2 == nullptr) return false; - if (tok1->str() != tok2->str()) + if (tok1->str() != tok2->str() || tok1->varId() != tok2->varId()) return false; if (tok1->isExpandedMacro() || tok2->isExpandedMacro()) return false; diff --git a/test/testother.cpp b/test/testother.cpp index 231c765a4..8fea48b41 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4729,6 +4729,10 @@ private: // make sure there are not "same expression" fp when there are different ({}) expressions check("void f(long x) { if (({ 1+2; }) == ({3+4};)) {} }"); ASSERT_EQUALS("", errout.str()); + + // #5535: Reference named like its type + check("void foo() { UMSConfig& UMSConfig = GetUMSConfiguration(); }"); + ASSERT_EQUALS("", errout.str()); } void duplicateIf1() { // ticket 3689 ( avoid false positive )