Fix #10661 FP extern function reported as unused (#4279)

This commit is contained in:
chrchr-github 2022-07-14 20:59:58 +02:00 committed by GitHub
parent 2543dc97d2
commit 53cd3dc665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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() {