[clang] [clang] emit an error when the same identifier appears with both internal and external linkage in a translation unit (PR #78064)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 5 09:35:03 PST 2024
================
@@ -4754,6 +4754,11 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
return New->setInvalidDecl();
}
+ if (Old->getFormalLinkage() != New->getFormalLinkage()) {
+ Diag(New->getLocation(), diag::err_multiple_linkage) << New->getDeclName();
+ return New->setInvalidDecl();
+ }
----------------
AaronBallman wrote:
I think http://eel.is/c++draft/dcl.stc#example-1 has a lot of good examples that are worth looking at.
We do a lot of this checking already, starting from https://github.com/llvm/llvm-project/blob/cb8d83a77c25e529f58eba17bb1ec76069a04e90/clang/lib/Sema/SemaDecl.cpp#L4643 and the issue might relate to the FIXME at https://github.com/llvm/llvm-project/blob/cb8d83a77c25e529f58eba17bb1ec76069a04e90/clang/lib/Sema/SemaDecl.cpp#L4696
https://github.com/llvm/llvm-project/pull/78064
More information about the cfe-commits
mailing list