[PATCH] D35484: Add a warning for missing '#pragma pack (pop)' and suspicious '#pragma pack' uses when including files

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 19 06:01:58 PDT 2017


arphaman added a comment.

This triggered a warning in LLVM itself, in CoverageMapping.h :

  error: non-default #pragma pack value might change the alignment of
  struct or union members in the included file [-Werror,-Wpragma-pack]
  #include "llvm/ProfileData/InstrProfData.inc"
           ^
  /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h:513:1:
  note: previous '#pragma pack' directive that modifies alignment is
  here
  LLVM_PACKED_START
  ^
  /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Compiler.h:349:28:
  note: expanded from macro 'LLVM_PACKED_START'
  # define LLVM_PACKED_START _Pragma("pack(push, 1)")
                             ^
  <scratch space>:14:2: note: expanded from here
   pack(push, 1)

I think I might tweak this diagnostic to avoid warning in that case. It might be better to just avoid warning about "non-default #pragma pack value might change the alignment of
struct or union members in the included file" until a first record declaration is encountered in the included file. This will avoid the warning in LLVM as the packed class is declared in the file that includes the header.


Repository:
  rL LLVM

https://reviews.llvm.org/D35484





More information about the cfe-commits mailing list