MS attributes and GNUAttributesAllowed

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MS attributes and GNUAttributesAllowed

dawn

I see that MS attributes were added "if (GNUAttributesAllowed)" is true
(see ParseTypeQualifierListOpt in lib/Parse/ParseDecl.cpp) - I find that
a bit confusing.  The grammar at the top also implies MS attributes are
handled under the [GNU] attributes.  I'm about to add a new Borland
attribute, but would like to clean this up.

There are a few ways to clean this up:
    1. Add another bool parameter for each kind of attribute.  This could get
        ugly fast.
    2. Change 'GNUAttributesAllowed' to 'AttributesAllowed'.  The problem
    with this is that there's no way to disable MS (or other) attributes
        from sneaking in when GNU attributes are enabled (and vice versa).
    3. Turn the bools GNUAttributesAllowed and CXX0XAttributesAllowed
        into flags and add bitfields for GNU, CXX0X, MS and Borland.

I like #3, but this requires a little reworking of the attributes
handling and I'm a bit new to be messing with this just yet :-).
For now I'll just copy what MS did and go with #2.

Opinions?  Thoughts?  
-Dawn
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: MS attributes and GNUAttributesAllowed

Douglas Gregor

On Aug 31, 2010, at 2:22 PM, [hidden email] wrote:

>
> I see that MS attributes were added "if (GNUAttributesAllowed)" is true
> (see ParseTypeQualifierListOpt in lib/Parse/ParseDecl.cpp) - I find that
> a bit confusing.  The grammar at the top also implies MS attributes are
> handled under the [GNU] attributes.

It may have been a convenience, since GCC implements __fastcall, __thiscall, etc. from the Microsoft world, but I agree that it is confusing.

>  I'm about to add a new Borland
> attribute, but would like to clean this up.
>
> There are a few ways to clean this up:
>    1. Add another bool parameter for each kind of attribute.  This could get
> ugly fast.

Ick.


>    2. Change 'GNUAttributesAllowed' to 'AttributesAllowed'.  The problem
>     with this is that there's no way to disable MS (or other) attributes
> from sneaking in when GNU attributes are enabled (and vice versa).
>    3. Turn the bools GNUAttributesAllowed and CXX0XAttributesAllowed
> into flags and add bitfields for GNU, CXX0X, MS and Borland.
>
> I like #3, but this requires a little reworking of the attributes
> handling and I'm a bit new to be messing with this just yet :-).
> For now I'll just copy what MS did and go with #2.


#3 would be best, of course. #2 is okay if, practically speaking, it doesn't change any behavior.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev