[PATCH] D25106: Packed member warning: Use the typedef name for anonymous structures when it is available

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 3 13:44:11 PDT 2016


aaron.ballman added inline comments.


> SemaChecking.cpp:11284
> +    if (ND->getName().empty()) {
> +      if (const auto *TypedefDecl = m.RD->getTypedefNameForAnonDecl())
> +        ND = TypedefDecl;

Please don't use `auto` here since the type is not spelled directly in the initialization.

> address-packed.c:187
> +    return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefUnionArguable'}}
> +}

Can you add a test along the lines of:

  struct S {
    union {
      char c;
      int x;
    } __attribute__((packed));
  };
  
  int *ugh(S *s) {
    return &s->x;   
  }

https://reviews.llvm.org/D25106





More information about the cfe-commits mailing list