* Handle float values * Fix #11237 checkLibraryNoReturn with unassigned object
This commit is contained in:
parent
a62c3ea90e
commit
dd927aab9b
|
@ -7115,22 +7115,14 @@ bool Tokenizer::isScopeNoReturn(const Token *endScopeToken, bool *unknown) const
|
|||
if (unknown)
|
||||
*unknown = !unknownFunc.empty();
|
||||
if (!unknownFunc.empty() && mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) {
|
||||
// Is function global?
|
||||
bool globalFunction = true;
|
||||
bool warn = true;
|
||||
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
|
||||
const Token * const ftok = endScopeToken->linkAt(-2)->previous();
|
||||
if (ftok &&
|
||||
ftok->isName() &&
|
||||
ftok->function() &&
|
||||
ftok->function()->nestedIn &&
|
||||
ftok->function()->nestedIn->type != Scope::eGlobal) {
|
||||
globalFunction = false;
|
||||
}
|
||||
if (ftok && ftok->type()) // constructor call
|
||||
warn = false;
|
||||
}
|
||||
|
||||
// don't warn for nonglobal functions (class methods, functions hidden in namespaces) since they can't be configured yet
|
||||
// FIXME: when methods and namespaces can be configured properly, remove the "globalFunction" check
|
||||
if (globalFunction) {
|
||||
if (warn) {
|
||||
reportError(endScopeToken->previous(),
|
||||
Severity::information,
|
||||
"checkLibraryNoReturn",
|
||||
|
|
|
@ -2406,6 +2406,20 @@ private:
|
|||
" static_assert(1 == sizeof(char), \"test\");\n"
|
||||
"}\n", /*cpp*/ true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("namespace pal {\n" // #11237
|
||||
" struct AutoTimer {};\n"
|
||||
"}\n"
|
||||
"int main() {\n"
|
||||
" pal::AutoTimer();\n"
|
||||
"}\n", /*cpp*/ true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct AutoTimer {};\n"
|
||||
"int main() {\n"
|
||||
" AutoTimer();\n"
|
||||
"}\n", /*cpp*/ true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void ptrptr() {
|
||||
|
|
Loading…
Reference in New Issue