| 3744 | } |
| 3745 | |
| 3746 | void CheckOtherImpl::checkUnusedLabel() |
| 3747 | { |
| 3748 | if (!mSettings.severity.isEnabled(Severity::style) && !mSettings.severity.isEnabled(Severity::warning) && !mSettings.isPremiumEnabled("unusedLabel")) |
| 3749 | return; |
| 3750 | |
| 3751 | logChecker("CheckOther::checkUnusedLabel"); // style,warning |
| 3752 | |
| 3753 | const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); |
| 3754 | for (const Scope * scope : symbolDatabase->functionScopes) { |
| 3755 | const bool hasIfdef = mTokenizer->hasIfdef(scope->bodyStart, scope->bodyEnd); |
| 3756 | for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) { |
| 3757 | if (!tok->scope()->isExecutable()) |
| 3758 | tok = tok->scope()->bodyEnd; |
| 3759 | |
| 3760 | if (Token::Match(tok, "{|}|; %name% :") && !tok->tokAt(1)->isKeyword()) { |
| 3761 | const std::string tmp("goto " + tok->strAt(1)); |
| 3762 | if (!Token::findsimplematch(scope->bodyStart->next(), tmp.c_str(), tmp.size(), scope->bodyEnd->previous()) && !tok->next()->isExpandedMacro()) |
| 3763 | unusedLabelError(tok->next(), tok->next()->scope()->type == ScopeType::eSwitch, hasIfdef); |
| 3764 | } |
| 3765 | } |
| 3766 | } |
| 3767 | } |
| 3768 | |
| 3769 | void CheckOtherImpl::unusedLabelError(const Token* tok, bool inSwitch, bool hasIfdef) |
| 3770 | { |
no test coverage detected