Skip to content

Commit ec4c979

Browse files
IOBYTEdanmar
authored andcommitted
fix daca error: Internal Error: Invalid syntax (#2452)
* fix daca error: Internal Error: Invalid syntax * fix cppcheck warnings
1 parent 3fdf1b8 commit ec4c979

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,9 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
24112411
if (!func->hasBody()) {
24122412
const Token *closeParen = (*tok)->next()->link();
24132413
if (closeParen) {
2414-
if (Token::Match(closeParen, ") noexcept| = default ;")) {
2414+
if (Token::Match(closeParen, ") noexcept| = default ;") ||
2415+
(Token::simpleMatch(closeParen, ") noexcept (") &&
2416+
Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) {
24152417
func->isDefault(true);
24162418
return;
24172419
}
@@ -2483,7 +2485,9 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
24832485
// normal function?
24842486
const Token *closeParen = (*tok)->next()->link();
24852487
if (closeParen) {
2486-
if (Token::Match(closeParen, ") noexcept| = default ;")) {
2488+
if (Token::Match(closeParen, ") noexcept| = default ;") ||
2489+
(Token::simpleMatch(closeParen, ") noexcept (") &&
2490+
Token::simpleMatch(closeParen->linkAt(2), ") = default ;"))) {
24872491
func->isDefault(true);
24882492
return;
24892493
}

test/testsymboldatabase.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class TestSymbolDatabase: public TestFixture {
308308
TEST_CASE(symboldatabase81); // #9411
309309
TEST_CASE(symboldatabase82);
310310
TEST_CASE(symboldatabase83); // #9431
311+
TEST_CASE(symboldatabase84);
311312

312313
TEST_CASE(createSymbolDatabaseFindAllScopes1);
313314

@@ -4442,6 +4443,41 @@ class TestSymbolDatabase: public TestFixture {
44424443
ASSERT_EQUALS("", errout.str());
44434444
}
44444445

4446+
void symboldatabase84() {
4447+
{
4448+
const bool old = settings1.debugwarnings;
4449+
settings1.debugwarnings = true;
4450+
GET_SYMBOL_DB("struct a { a() noexcept(false); };\n"
4451+
"a::a() noexcept(false) = default;");
4452+
settings1.debugwarnings = old;
4453+
const Scope *scope = db->findScopeByName("a");
4454+
ASSERT(scope);
4455+
ASSERT(scope->functionList.size() == 1);
4456+
ASSERT(scope->functionList.front().name() == "a");
4457+
ASSERT(scope->functionList.front().hasBody() == false);
4458+
ASSERT(scope->functionList.front().isConstructor() == true);
4459+
ASSERT(scope->functionList.front().isDefault() == true);
4460+
ASSERT(scope->functionList.front().isNoExcept() == false);
4461+
ASSERT_EQUALS("", errout.str());
4462+
}
4463+
{
4464+
const bool old = settings1.debugwarnings;
4465+
settings1.debugwarnings = true;
4466+
GET_SYMBOL_DB("struct a { a() noexcept(true); };\n"
4467+
"a::a() noexcept(true) = default;");
4468+
settings1.debugwarnings = old;
4469+
const Scope *scope = db->findScopeByName("a");
4470+
ASSERT(scope);
4471+
ASSERT(scope->functionList.size() == 1);
4472+
ASSERT(scope->functionList.front().name() == "a");
4473+
ASSERT(scope->functionList.front().hasBody() == false);
4474+
ASSERT(scope->functionList.front().isConstructor() == true);
4475+
ASSERT(scope->functionList.front().isDefault() == true);
4476+
ASSERT(scope->functionList.front().isNoExcept() == true);
4477+
ASSERT_EQUALS("", errout.str());
4478+
}
4479+
}
4480+
44454481
void createSymbolDatabaseFindAllScopes1() {
44464482
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
44474483
ASSERT(db->scopeList.size() == 3);

0 commit comments

Comments
 (0)