steplong updated this revision to Diff 440268.
steplong added a comment.
- Use `getCanonicalDecl()`. This does make us reject (MSVC rejects it already
because of conflicting declarations):
static void f();
extern "C" { static void f(); }
static void f() {}
- Error if not function decl
hans added inline comments.
Comment at: clang/lib/Sema/SemaAttr.cpp:811
return;
}
Since the pragma only applies to functions, maybe we should error here if the
decl is not a FunctionDecl?
Comment at: clang/lib/Sema/SemaAttr.cpp:8
steplong added a comment.
This does make us accept, but MSVC doesn't:
static void f();
extern "C" {
static void f();
}
#pragma alloc_text(c, f);
static void f() {}
MSVC and GCC fail with an error for conflicting declaration.
GCC: https://godbolt.org/z/Tavvx88E4
MSVC: https://godbol
steplong created this revision.
Herald added a project: All.
steplong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
MSVC's pragma alloc_text accepts a function that was redeclared in
a non extern-C context if the previous declaration was