================
@@ -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 don't think this logic is correct. See C23 6.2.2 (especially p4): 

> For an identifier declared with the storage-class specifier extern in a scope 
> in which a prior declaration of that identifier is visible, if the prior 
> declaration specifies internal or external linkage, the linkage of the 
> identifier at the later declaration is the same as the linkage specified at 
> the prior declaration. 

So a mismatch between linkages isn't always an issue to be diagnosed: 
https://godbolt.org/z/rx7rGhv7c (notice how the local variable `x` is not an 
issue despite having different linkage from the `extern` declaration: 
https://godbolt.org/z/Yjqo4eY9M) This is possibly why you're getting as many CI 
failures as you're seeing.

https://github.com/llvm/llvm-project/pull/78064
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to