r179743 - [Parser] Handle #pragma pack/align inside C structs.

jahanian fjahanian at apple.com
Thu Apr 18 08:04:33 PDT 2013


This needs an IRGen test to show that pragma is effective.

- Fariborz

On Apr 17, 2013, at 6:42 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:

> Author: akirtzidis
> Date: Wed Apr 17 20:42:35 2013
> New Revision: 179743
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179743&view=rev
> Log:
> [Parser] Handle #pragma pack/align inside C structs.
> 
> Fixes PR13580. Patch by Serge Pavlov!
> 
> Modified:
>    cfe/trunk/lib/Parse/ParseDecl.cpp
>    cfe/trunk/test/Parser/pragma-options.c
>    cfe/trunk/test/Parser/pragma-pack.c
> 
> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=179743&r1=179742&r2=179743&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Apr 17 20:42:35 2013
> @@ -3230,6 +3230,16 @@ void Parser::ParseStructUnionBody(Source
>       continue;
>     }
> 
> +    if (Tok.is(tok::annot_pragma_pack)) {
> +      HandlePragmaPack();
> +      continue;
> +    }
> +
> +    if (Tok.is(tok::annot_pragma_align)) {
> +      HandlePragmaAlign();
> +      continue;
> +    }
> +
>     if (!Tok.is(tok::at)) {
>       struct CFieldCallback : FieldCallback {
>         Parser &P;
> 
> Modified: cfe/trunk/test/Parser/pragma-options.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/pragma-options.c?rev=179743&r1=179742&r2=179743&view=diff
> ==============================================================================
> --- cfe/trunk/test/Parser/pragma-options.c (original)
> +++ cfe/trunk/test/Parser/pragma-options.c Wed Apr 17 20:42:35 2013
> @@ -20,3 +20,15 @@
> #pragma align=reset
> #pragma align=mac68k
> #pragma align=power
> +
> +// PR13580
> +struct S
> +{
> +  char a[3];
> +#pragma align=packed
> +  struct T
> +  {
> +    char b;
> +    int c;
> +  } d;
> +};
> 
> Modified: cfe/trunk/test/Parser/pragma-pack.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/pragma-pack.c?rev=179743&r1=179742&r2=179743&view=diff
> ==============================================================================
> --- cfe/trunk/test/Parser/pragma-pack.c (original)
> +++ cfe/trunk/test/Parser/pragma-pack.c Wed Apr 17 20:42:35 2013
> @@ -30,3 +30,17 @@
> 
> _Pragma("pack(push)")
> /* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ _Pragma("pack(push,)") 
> +
> +// PR13580
> +struct S
> +{
> +  char a[3];
> +#pragma pack(1)
> +  struct T
> +  {
> +    char b;
> +    int c;
> +  } d;
> +#pragma pack()
> +  int e;
> +};
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130418/c73f5224/attachment.html>


More information about the cfe-commits mailing list