* 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)
|
if (unknown)
|
||||||
*unknown = !unknownFunc.empty();
|
*unknown = !unknownFunc.empty();
|
||||||
if (!unknownFunc.empty() && mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) {
|
if (!unknownFunc.empty() && mSettings->checkLibrary && mSettings->severity.isEnabled(Severity::information)) {
|
||||||
// Is function global?
|
bool warn = true;
|
||||||
bool globalFunction = true;
|
|
||||||
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
|
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
|
||||||
const Token * const ftok = endScopeToken->linkAt(-2)->previous();
|
const Token * const ftok = endScopeToken->linkAt(-2)->previous();
|
||||||
if (ftok &&
|
if (ftok && ftok->type()) // constructor call
|
||||||
ftok->isName() &&
|
warn = false;
|
||||||
ftok->function() &&
|
|
||||||
ftok->function()->nestedIn &&
|
|
||||||
ftok->function()->nestedIn->type != Scope::eGlobal) {
|
|
||||||
globalFunction = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't warn for nonglobal functions (class methods, functions hidden in namespaces) since they can't be configured yet
|
if (warn) {
|
||||||
// FIXME: when methods and namespaces can be configured properly, remove the "globalFunction" check
|
|
||||||
if (globalFunction) {
|
|
||||||
reportError(endScopeToken->previous(),
|
reportError(endScopeToken->previous(),
|
||||||
Severity::information,
|
Severity::information,
|
||||||
"checkLibraryNoReturn",
|
"checkLibraryNoReturn",
|
||||||
|
|
|
@ -2406,6 +2406,20 @@ private:
|
||||||
" static_assert(1 == sizeof(char), \"test\");\n"
|
" static_assert(1 == sizeof(char), \"test\");\n"
|
||||||
"}\n", /*cpp*/ true);
|
"}\n", /*cpp*/ true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void ptrptr() {
|
||||||
|
|
Loading…
Reference in New Issue