From 6f4ce486a219efec0f3f7f6f29ac585b4b65745f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 8 Sep 2021 06:56:45 +0200 Subject: [PATCH] Fix FP in constVariable --- lib/astutils.cpp | 2 +- test/testother.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index f277ab488..1a77296ee 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1903,7 +1903,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti return false; // not a function => variable not changed if (Token::simpleMatch(tok, "{") && isTrivialConstructor(tok)) return false; - if (tok->isKeyword() && !isCPPCastKeyword(tok)) + if (tok->isKeyword() && !isCPPCastKeyword(tok) && tok->str().compare(0,8,"operator") != 0) return false; const Token * parenTok = tok->next(); if (Token::simpleMatch(parenTok, "<") && parenTok->link()) diff --git a/test/testother.cpp b/test/testother.cpp index 1653e712e..44406a9c3 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1801,6 +1801,13 @@ private: check(code, &s64); ASSERT_EQUALS("", errout.str()); } + + check("Writer* getWriter();\n" + "\n" + "void foo(Buffer& buffer) {\n" + " getWriter()->operator<<(buffer);\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void passedByValue_externC() {