efriedma-quic wrote:

> **1. The alias stays hidden when it should be exported.**
> 
> ```c
> int target(void);
> #pragma weak alias = target
> int alias(void) __attribute__((visibility("default")));
> int target(void) { return 0; }
> ```
> 
> With `-fvisibility=hidden`, the explicit `visibility("default")` should make 
> `alias` visible outside the shared library. Clang warns and ignores the 
> attribute, leaving it hidden. This limitation also exists before this PR.

As long as we trigger the warning ("attribute declaration must precede 
definition"), this is probably fine.

If we think this is important, we would need to defer processing the pragma to 
the end of the translation unit, or something like that.

> **2. The namespace example fails to compile.**
> 
> ```c++
> #pragma weak alias = target
> namespace N {
> extern "C" int alias;
> extern "C" {
> int target = 3;
> }
> }
> ```

I don't think it's worth implementing a new kind of name lookup to handle weird 
code like this.

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

Reply via email to