[cfe-commits] r161523 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp test/Sema/pragma-pack-6.c

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Aug 8 14:15:02 PDT 2012


Thanks and sorry for the breakage!

On 8 August 2012 17:08, Eli Friedman <eli.friedman at gmail.com> wrote:
> Author: efriedma
> Date: Wed Aug  8 16:08:34 2012
> New Revision: 161523
>
> URL: http://llvm.org/viewvc/llvm-project?rev=161523&view=rev
> Log:
> Don't add attributes for "#pragma pack" and friends to tag declarations which
> are not definitions. This follows the behavior of both gcc and earlier
> versions of clang. Regression from r156531.  <rdar://problem/12048621>.
>
>
> Added:
>     cfe/trunk/test/Sema/pragma-pack-6.c
> Modified:
>     cfe/trunk/lib/Sema/SemaDecl.cpp
>     cfe/trunk/lib/Sema/SemaTemplate.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=161523&r1=161522&r2=161523&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Aug  8 16:08:34 2012
> @@ -8807,9 +8807,10 @@
>      // many points during the parsing of a struct declaration (because
>      // the #pragma tokens are effectively skipped over during the
>      // parsing of the struct).
> -    AddAlignmentAttributesForRecord(RD);
> -
> -    AddMsStructLayoutForRecord(RD);
> +    if (TUK == TUK_Definition) {
> +      AddAlignmentAttributesForRecord(RD);
> +      AddMsStructLayoutForRecord(RD);
> +    }
>    }
>
>    if (ModulePrivateLoc.isValid()) {
>
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=161523&r1=161522&r2=161523&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Aug  8 16:08:34 2012
> @@ -1064,8 +1064,10 @@
>
>    // Add alignment attributes if necessary; these attributes are checked when
>    // the ASTContext lays out the structure.
> -  AddAlignmentAttributesForRecord(NewClass);
> -  AddMsStructLayoutForRecord(NewClass);
> +  if (TUK == TUK_Definition) {
> +    AddAlignmentAttributesForRecord(NewClass);
> +    AddMsStructLayoutForRecord(NewClass);
> +  }
>
>    ClassTemplateDecl *NewTemplate
>      = ClassTemplateDecl::Create(Context, SemanticContext, NameLoc,
>
> Added: cfe/trunk/test/Sema/pragma-pack-6.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-pack-6.c?rev=161523&view=auto
> ==============================================================================
> --- cfe/trunk/test/Sema/pragma-pack-6.c (added)
> +++ cfe/trunk/test/Sema/pragma-pack-6.c Wed Aug  8 16:08:34 2012
> @@ -0,0 +1,16 @@
> +// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
> +
> +// Pragma pack handling with tag declarations
> +
> +struct X;
> +
> +#pragma pack(2)
> +struct X { int x; };
> +struct Y;
> +#pragma pack()
> +
> +struct Y { int y; };
> +
> +extern int check[__alignof(struct X) == 2 ? 1 : -1];
> +extern int check[__alignof(struct Y) == 4 ? 1 : -1];
> +
>
>
> _______________________________________________
> 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