fix daca error: Internal Error: Invalid syntax (#2452)

* fix daca error: Internal Error: Invalid syntax

* fix cppcheck warnings
This commit is contained in:
IOBYTE 2019-12-18 05:48:36 -05:00 committed by Daniel Marjamäki
parent 3fdf1b806a
commit ec4c979cd8
2 changed files with 42 additions and 2 deletions

View File

@ -2411,7 +2411,9 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
if (!func->hasBody()) { if (!func->hasBody()) {
const Token *closeParen = (*tok)->next()->link(); const Token *closeParen = (*tok)->next()->link();
if (closeParen) { if (closeParen) {
if (Token::Match(closeParen, ") noexcept| = default ;")) { if (Token::Match(closeParen, ") noexcept| = default ;") ||
(Token::simpleMatch(closeParen, ") noexcept (") &&
Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) {
func->isDefault(true); func->isDefault(true);
return; return;
} }
@ -2483,7 +2485,9 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
// normal function? // normal function?
const Token *closeParen = (*tok)->next()->link(); const Token *closeParen = (*tok)->next()->link();
if (closeParen) { if (closeParen) {
if (Token::Match(closeParen, ") noexcept| = default ;")) { if (Token::Match(closeParen, ") noexcept| = default ;") ||
(Token::simpleMatch(closeParen, ") noexcept (") &&
Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) {
func->isDefault(true); func->isDefault(true);
return; return;
} }

View File

@ -308,6 +308,7 @@ private:
TEST_CASE(symboldatabase81); // #9411 TEST_CASE(symboldatabase81); // #9411
TEST_CASE(symboldatabase82); TEST_CASE(symboldatabase82);
TEST_CASE(symboldatabase83); // #9431 TEST_CASE(symboldatabase83); // #9431
TEST_CASE(symboldatabase84);
TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes1);
@ -4442,6 +4443,41 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void symboldatabase84() {
{
const bool old = settings1.debugwarnings;
settings1.debugwarnings = true;
GET_SYMBOL_DB("struct a { a() noexcept(false); };\n"
"a::a() noexcept(false) = default;");
settings1.debugwarnings = old;
const Scope *scope = db->findScopeByName("a");
ASSERT(scope);
ASSERT(scope->functionList.size() == 1);
ASSERT(scope->functionList.front().name() == "a");
ASSERT(scope->functionList.front().hasBody() == false);
ASSERT(scope->functionList.front().isConstructor() == true);
ASSERT(scope->functionList.front().isDefault() == true);
ASSERT(scope->functionList.front().isNoExcept() == false);
ASSERT_EQUALS("", errout.str());
}
{
const bool old = settings1.debugwarnings;
settings1.debugwarnings = true;
GET_SYMBOL_DB("struct a { a() noexcept(true); };\n"
"a::a() noexcept(true) = default;");
settings1.debugwarnings = old;
const Scope *scope = db->findScopeByName("a");
ASSERT(scope);
ASSERT(scope->functionList.size() == 1);
ASSERT(scope->functionList.front().name() == "a");
ASSERT(scope->functionList.front().hasBody() == false);
ASSERT(scope->functionList.front().isConstructor() == true);
ASSERT(scope->functionList.front().isDefault() == true);
ASSERT(scope->functionList.front().isNoExcept() == true);
ASSERT_EQUALS("", errout.str());
}
}
void createSymbolDatabaseFindAllScopes1() { void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3); ASSERT(db->scopeList.size() == 3);