Merge branch 'master' of https://github.com/danmar/cppcheck
This commit is contained in:
commit
40e8908558
|
@ -101,7 +101,7 @@ public:
|
|||
static bool sameCID(const ErrorItem &errorItem1, const ErrorItem &errorItem2);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ErrorItem);
|
||||
Q_DECLARE_METATYPE(ErrorItem)
|
||||
|
||||
/**
|
||||
* @brief A class containing error data for one shown error line.
|
||||
|
|
|
@ -1363,5 +1363,5 @@ void ResultsTree::showInconclusiveColumn(bool show)
|
|||
void ResultsTree::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
QTreeView::currentChanged(current, previous);
|
||||
emit selectionChanged(current);
|
||||
emit treeSelectionChanged(current);
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ signals:
|
|||
*
|
||||
* @param current Model index to specify new selected item.
|
||||
*/
|
||||
void selectionChanged(const QModelIndex ¤t);
|
||||
void treeSelectionChanged(const QModelIndex ¤t);
|
||||
|
||||
/**
|
||||
* Selected item(s) has been tagged
|
||||
|
|
|
@ -51,7 +51,7 @@ ResultsView::ResultsView(QWidget * parent) :
|
|||
|
||||
connect(mUI.mTree, &ResultsTree::resultsHidden, this, &ResultsView::resultsHidden);
|
||||
connect(mUI.mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
|
||||
connect(mUI.mTree, &ResultsTree::selectionChanged, this, &ResultsView::updateDetails);
|
||||
connect(mUI.mTree, &ResultsTree::treeSelectionChanged, this, &ResultsView::updateDetails);
|
||||
connect(mUI.mTree, &ResultsTree::tagged, this, &ResultsView::tagged);
|
||||
connect(mUI.mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds);
|
||||
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);
|
||||
|
|
|
@ -5441,7 +5441,7 @@ Token *Tokenizer::simplifyAddBracesToCommand(Token *tok)
|
|||
syntaxError(tok);
|
||||
}
|
||||
}
|
||||
} else if (tok->str()=="if") {
|
||||
} else if (tok->str()=="if" && !Token::simpleMatch(tok->tokAt(-2), "operator \"\"")) {
|
||||
tokEnd=simplifyAddBracesPair(tok,true);
|
||||
if (!tokEnd)
|
||||
return nullptr;
|
||||
|
@ -9118,8 +9118,10 @@ void Tokenizer::findGarbageCode() const
|
|||
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "if|while|for|switch")) { // if|while|for|switch (EXPR) { ... }
|
||||
if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,"))
|
||||
syntaxError(tok);
|
||||
if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,")) {
|
||||
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if"))
|
||||
syntaxError(tok);
|
||||
}
|
||||
if (Token::Match(tok->previous(), "[(,]"))
|
||||
continue;
|
||||
if (!Token::Match(tok->next(), "( !!)"))
|
||||
|
@ -9150,8 +9152,10 @@ void Tokenizer::findGarbageCode() const
|
|||
const Token *prev = tok;
|
||||
while (prev && prev->isName())
|
||||
prev = prev->previous();
|
||||
if (Token::Match(prev, "%op%|%num%|%str%|%char%"))
|
||||
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
|
||||
if (Token::Match(prev, "%op%|%num%|%str%|%char%")) {
|
||||
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if"))
|
||||
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
|
||||
}
|
||||
}
|
||||
|
||||
// case keyword must be inside switch
|
||||
|
|
|
@ -399,6 +399,7 @@ private:
|
|||
TEST_CASE(simplifyOperatorName11); // #8889
|
||||
TEST_CASE(simplifyOperatorName12); // #9110
|
||||
TEST_CASE(simplifyOperatorName13); // user defined literal
|
||||
TEST_CASE(simplifyOperatorName14); // std::complex operator "" if
|
||||
|
||||
TEST_CASE(simplifyNullArray);
|
||||
|
||||
|
@ -6357,11 +6358,24 @@ private:
|
|||
}
|
||||
|
||||
void simplifyOperatorName13() { // user defined literal
|
||||
const char code[] = "unsigned long operator""_numch(const char *ch, unsigned long size);";
|
||||
ASSERT_EQUALS("unsigned long operator""_numch ( const char * ch , unsigned long size ) ;",
|
||||
const char code[] = "unsigned long operator\"\"_numch(const char *ch, unsigned long size);";
|
||||
ASSERT_EQUALS("unsigned long operator\"\"_numch ( const char * ch , unsigned long size ) ;",
|
||||
tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyOperatorName14() { // std::complex operator "" if
|
||||
{
|
||||
const char code[] = "constexpr std::complex<float> operator\"\"if(long double __num);";
|
||||
ASSERT_EQUALS("const std :: complex < float > operator\"\"if ( long double __num ) ;",
|
||||
tokenizeAndStringify(code));
|
||||
}
|
||||
{
|
||||
const char code[] = "constexpr std::complex<float> operator\"\"if(long double __num) { }";
|
||||
ASSERT_EQUALS("const std :: complex < float > operator\"\"if ( long double __num ) { }",
|
||||
tokenizeAndStringify(code));
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyNullArray() {
|
||||
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue