mstorsjo wrote:

> > I think the main key word is external linkage in any case.
> 
> But then wouldn't it be accepted on:
> 
> ```
> struct T {
>   SA static int i;
> };
> ```
> 
> because that still has external linkage: https://godbolt.org/z/vafPxa4jh ?

Right, I guess. In that sense it feels like it boils down to the distinction 
between declaration and definition. But for regular extern variables, we do 
accept selectany on a pure declaration, and MSVC also accepts that. While 
selectany shouldn't make any difference for a consumer of the declaration, it 
only makes a difference for the definition.

I guess I don't know which language level nuance should be used for 
distinguishing these cases then... But IMO it needs to be possible to set this 
attribute on any definition of a symbol with external linkage. Setting it on a 
declaration of such symbols isn't strictly needed but perhaps is accepted for 
other reasons.

https://github.com/llvm/llvm-project/pull/189641
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to