================ @@ -2380,7 +2380,7 @@ FunctionDecl *Sema::CreateBuiltin(IdentifierInfo *II, QualType Type, } FunctionDecl *New = FunctionDecl::Create(Context, Parent, Loc, Loc, II, Type, - /*TInfo=*/nullptr, SC_Extern, + /*TInfo=*/nullptr, SC_None, ---------------- temyurchenko wrote:
> > That's not actually correct -- the declaration of a function at block scope > > should definitely _not_ be extern, it should have no linkage: > > https://godbolt.org/z/81fMaPaTq > > I may be wrong to rely on cppreference, but the following page tells that > indeed a function at a block scope has implicit `extern`, which could also be > made explicit: https://en.cppreference.com/w/c/language/storage_duration. > > I also checked your example locally by compiling (via clang) `main.c` with an > additional `defs.c`: main.c: > > ```c > int main(void) { > void f(); > extern void g(); > > f(); > g(); > > return 0; > } > ``` > > defs.c: > > ```c > #include <stdio.h> > > void f() { > printf("f\n"); > } > > void g() { > printf("g\n"); > } > ``` > > The executable works as expected. > > I will also take a look at the C99 standard draft. Paragraph 6.2.2.5 says: > If the declaration of an identifier for a function has no storage-class > specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern. If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external. Thus, seemingly confirming that a function declared at the block scope is declared with an implicit `extern`. https://github.com/llvm/llvm-project/pull/93913 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits