Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition

2022-12-06 Thread Jonathan Wakely via Gcc
On Tue, 6 Dec 2022 at 20:32, Gavin Ray wrote:
>
> Ah got it, didn't know that (handy, will save me duplicating a bunch of 
> attributes).
> Thanks Jonathan!

The Clang doc acually show all the forms that can be used for each attribute:

https://clang.llvm.org/docs/AttributeReference.html#may-alias

"GNU" means __attribute__((may_alias)) and the C++11 and C2x columns
show that [[gnu::may_alias]] is the right way to use it.

Clang-specific attributes use clang:: instead e.g.
https://clang.llvm.org/docs/AttributeReference.html#preserve-all


Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition

2022-12-06 Thread Gavin Ray via Gcc
Ah got it, didn't know that (handy, will save me duplicating a bunch of
attributes).
Thanks Jonathan!

On Tue, Dec 6, 2022 at 2:23 PM Jonathan Wakely 
wrote:

>
>
> On Tue, 6 Dec 2022, 18:36 Gavin Ray via Gcc,  wrote:
>
>> Oh, D'oh! Thanks Joseph, apologies for the needless email on the list
>> then.
>>
>> One final question if I could -- does that mean that in order to support
>> "may-alias" with the bracket syntax on both Clang and GCC, it would
>> require:
>>
>>  union [[gnu::may_alias]] [[clang::may_alias]] foo {};
>>
>
>
>
> Probably not. Clang accepts the gnu:: namespace for attributes that
> originated with GCC.
>
>
>


Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition

2022-12-06 Thread Jonathan Wakely via Gcc
On Tue, 6 Dec 2022, 18:36 Gavin Ray via Gcc,  wrote:

> Oh, D'oh! Thanks Joseph, apologies for the needless email on the list then.
>
> One final question if I could -- does that mean that in order to support
> "may-alias" with the bracket syntax on both Clang and GCC, it would
> require:
>
>  union [[gnu::may_alias]] [[clang::may_alias]] foo {};
>



Probably not. Clang accepts the gnu:: namespace for attributes that
originated with GCC.


Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition

2022-12-06 Thread Gavin Ray via Gcc
Oh, D'oh! Thanks Joseph, apologies for the needless email on the list then.

One final question if I could -- does that mean that in order to support
"may-alias" with the bracket syntax on both Clang and GCC, it would require:

 union [[gnu::may_alias]] [[clang::may_alias]] foo {};


On Tue, Dec 6, 2022 at 11:54 AM Joseph Myers 
wrote:

> On Mon, 5 Dec 2022, Gavin Ray via Gcc wrote:
>
> > union [[may_alias]] broken2 {};
>
> With [[]] syntax it's [[gnu::may_alias]], since it's not a standard
> attribute.
>
> --
> Joseph S. Myers
> jos...@codesourcery.com
>


Re: Using [[may_alias]] in C23/C++23 on a union works in neither post-"union" position, or at the end of the definition

2022-12-06 Thread Joseph Myers
On Mon, 5 Dec 2022, Gavin Ray via Gcc wrote:

> union [[may_alias]] broken2 {};

With [[]] syntax it's [[gnu::may_alias]], since it's not a standard 
attribute.

-- 
Joseph S. Myers
jos...@codesourcery.com