From 42ed5a6b98ae102b7b99fc9fed826fb6230158df Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Sun, 20 May 2018 16:58:05 -0400 Subject: [PATCH] Fixed #8581 (Delegating contructor warns for unintialized variables) (#1250) * Fixed #8581 (Delegating contructor warns for unintialized variables) * Replace Token::Match with isStandardType --- lib/symboldatabase.cpp | 7 +++++++ test/testconstructors.cpp | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 3fffcf299..047dea121 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5310,6 +5310,13 @@ void SymbolDatabase::setValueTypeInTokenList() } } + // function style cast + else if (tok->previous() && tok->previous()->isStandardType()) { + ValueType valuetype; + valuetype.type = ValueType::typeFromString(tok->previous()->str(), tok->previous()->isLong()); + setValueType(tok, valuetype); + } + // library function else if (tok->previous()) { const std::string& typestr(_settings->library.returnValueType(tok->previous())); diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 2fac2774c..ab37e7aac 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -1088,6 +1088,16 @@ private: "\n" "A::A() noexcept: A(0) {}"); ASSERT_EQUALS("", errout.str()); + + // Ticket #8581 + check("class A {\n" + "private:\n" + " int _a;\n" + "public:\n" + " A(int a) : _a(a) {}\n" + " A(float a) : A(int(a)) {}\n" + "};"); + ASSERT_EQUALS("", errout.str()); }