[clang] [Clang] Allow the use of [[gnu::visibility]] with #pragma clang attribute (PR #145653)

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 26 04:24:07 PDT 2025


philnik777 wrote:

> This is missing test coverage for the interesting cases.
> 
> I'm a bit worried about how easy it will be to apply this attribute in unexpected places. e.g., it will apply to member functions as well as free functions, will anyone expect that though?

This is explicitly documented, so I'd say yes. This is how the pragma works for better or worse.

> It also applies to special functions like `main`, though that's more a question of the attribute and less about the pragma.

I'm not sure whether this is a request for a test?

> What's the behavior going to be in C when you get an implicit function declaration in C89 mode? Does that declaration then pick up this attribute as well? How about other special member functions we define on behalf of the user?

I'm not 100% sure what you mean by "define on behalf of users". I've added a test for an explicitly defaulted special member. Note though that using `#pragma clang attribute` is basically like explicitly defaulting the special members and adding the attribute there.

https://github.com/llvm/llvm-project/pull/145653


More information about the cfe-commits mailing list