diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index e8cc100f3..b864d6cd6 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -75,6 +75,9 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi if (func->isAttributeConstructor() || func->isAttributeDestructor() || func->type != Function::eFunction || func->isOperator()) continue; + if (func->isExtern()) + continue; + // Don't care about templates if (tokenizer.isCPP() && func->templateDef != nullptr) continue; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a877fbd2b..815f92188 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2451,7 +2451,7 @@ const Token *Function::setFlags(const Token *tok1, const Scope *scope) isInlineKeyword(true); // extern function - if (tok1->str() == "extern") { + if (tok1->isExternC() || tok1->str() == "extern") { isExtern(true); } diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index 060da66f7..e2cd170f6 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -394,6 +394,10 @@ private: // Don't crash on wrong syntax check("int x __attribute__((constructor));\n" "int y __attribute__((destructor));"); + + // #10661 + check("extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) { return 0; }\n"); + ASSERT_EQUALS("", errout.str()); } void initializer_list() {