From 02682ab17dd5ef57e45a2727f52045c46112b83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 18 Jul 2021 14:54:25 +0200 Subject: [PATCH] missing return; Fixed FP when function ends with assert(0) --- lib/checkfunctions.cpp | 2 +- test/testfunctions.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 831103759..324b81581 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -338,7 +338,7 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib return nullptr; if (tok->str() == "goto" && !isForwardJump(tok)) return nullptr; - if (Token::Match(tok, "%name% (") && library.isnoreturn(tok)) + if (Token::Match(tok, "%name% (") && !library.isnotnoreturn(tok)) return nullptr; if (Token::Match(tok, "[;{}] %name% :")) return tok; diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index f38025a2f..f9a2ee003 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1487,6 +1487,9 @@ private: // noreturn function check("int f(int x) { exit(0); }"); ASSERT_EQUALS("", errout.str()); + + check("int f(int x) { assert(0); }"); + ASSERT_EQUALS("", errout.str()); } // NRVO check void returnLocalStdMove1() {