Do not set "pure" flag if function is declared as "= default" (#7101)

This commit is contained in:
PKEuS 2015-11-07 22:21:50 +01:00
parent dc823c65fa
commit fdb596fa05
2 changed files with 18 additions and 1 deletions

View File

@ -473,7 +473,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
else
tok = end->tokAt(2);
if (Token::Match(tok, "= %any% ;")) {
if (Token::Match(tok, "= !!default ;")) {
function.isPure(true);
tok = tok->tokAt(2);
}

View File

@ -236,6 +236,7 @@ private:
TEST_CASE(symboldatabase52); // #6581
TEST_CASE(isImplicitlyVirtual);
TEST_CASE(isPure);
TEST_CASE(isFunction); // UNKNOWN_MACRO(a,b) { .. }
@ -2305,6 +2306,22 @@ private:
}
}
void isPure() {
GET_SYMBOL_DB("class C {\n"
" void f() = 0;\n"
" C(B b) = 0;\n"
" C(C& c) = default;"
" void g();\n"
"};");
ASSERT(db && db->scopeList.back().functionList.size() == 4);
if (db && db->scopeList.back().functionList.size() == 4) {
std::list<Function>::const_iterator it = db->scopeList.back().functionList.begin();
ASSERT((it++)->isPure());
ASSERT((it++)->isPure());
ASSERT(!(it++)->isPure());
ASSERT(!(it++)->isPure());
}
}
void isFunction() { // #5602 - UNKNOWN_MACRO(a,b) { .. }
GET_SYMBOL_DB("TEST(a,b) {\n"
" std::vector<int> messages;\n"