From 774a8979a35198c34746651337e736e28fc69a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 12 Feb 2017 16:50:45 +0100 Subject: [PATCH] Fixed #7095 (False positive: (warning) Return value of function to_string() is not used.) --- lib/checkfunctions.cpp | 2 +- test/testfunctions.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 3076e6d72..2a367bd0a 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -157,7 +157,7 @@ void CheckFunctions::checkIgnoredReturnValue() const Scope * scope = symbolDatabase->functionScopes[i]; for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { // c++11 initialization - if (Token::Match(tok, "%var% {")) + if (Token::Match(tok, "%var% (| {")) tok = tok->linkAt(1); if (tok->varId() || !Token::Match(tok, "%name% (") || tok->strAt(-1) == ".") diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 4cd73c18c..953042523 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -894,13 +894,18 @@ private: " void * res{malloc(size)};\n" "}"); ASSERT_EQUALS("", errout.str()); - + // #7447 check("void foo() {\n" " int x{mystrcmp(a,b)};\n" "}", "test.cpp", &settings2); ASSERT_EQUALS("", errout.str()); - + + // #7905 + check("void foo() {\n" + " int x({mystrcmp(a,b)});\n" + "}", "test.cpp", &settings2); + ASSERT_EQUALS("", errout.str()); } };