[PATCH] Recognize __unaligned in more cases

Aaron Ballman aaron at aaronballman.com
Mon Nov 24 11:21:07 PST 2014


On Mon, Nov 24, 2014 at 12:43 PM, Nico Rieck <nico.rieck at gmail.com> wrote:
> The __unaligned keyword is currently only parsed in simple typedefs
> like:
>
>   typedef int __unaligned* foo;
>
> But it can also appear after a struct definition:
>
>   struct foo {...} __unaligned *x;
>
> and after the comma in declarator lists:
>
>   typedef int foo, __unaligned *bar;

When I compile with MSVC 2013, this example gives me:

main.cpp(5): warning C4228: nonstandard extension used : qualifiers
after comma in declarator list are ignored

> Both cases appear in current Windows SDK headers.
>
> Note: Specifying type qualifiers after the comma, as in the latter case,
> is a Microsoft extension. This patch only recognizes __unaligned.

> diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
> index fbf3337..bb07bd5 100644
> --- a/lib/Parse/ParseDecl.cpp
> +++ b/lib/Parse/ParseDecl.cpp
> @@ -1732,6 +1732,18 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
>      //    short x, __attribute__((common)) var;    -> declarator
>      MaybeParseGNUAttributes(D);
>
> +    // [MS] Type qualifiers after the comma is a Microsoft extensions. Currently
> +    // only __unaligned is parsed to support:
> +    //    typedef struct { ... } X, __unaligned *PX;

Why not handle other type qualifiers that Microsoft supports? Does
that turn out to be messy for some reason? It seems like we could just
call Parser::ParseMicrosoftTypeAttributes?

~Aaron

On Mon, Nov 24, 2014 at 12:43 PM, Nico Rieck <nico.rieck at gmail.com> wrote:
> The __unaligned keyword is currently only parsed in simple typedefs
> like:
>
>   typedef int __unaligned* foo;
>
> But it can also appear after a struct definition:
>
>   struct foo {...} __unaligned *x;
>
> and after the comma in declarator lists:
>
>   typedef int foo, __unaligned *bar;
>
> Both cases appear in current Windows SDK headers.
>
> Note: Specifying type qualifiers after the comma, as in the latter case,
> is a Microsoft extension. This patch only recognizes __unaligned.
>
> --Nico
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list