diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-11-07 00:35:20 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-11-07 00:35:20 +0000 |
commit | b68ec6b7ff4f8d7795b11cd361fec46725d57e4e (patch) | |
tree | 7d0bce5bbe8de47e7724a3097c3137a23ebae9c4 | |
parent | cb7b45e6d80c14d7d12db1eff17dc14b4ae8a35e (diff) |
Add missing check to warning for packed attribute. PR14259.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167510 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 3 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-attr.cpp | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 6db30bea9d..aef87c62f4 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -963,7 +963,8 @@ static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &Attr) { else if (FieldDecl *FD = dyn_cast<FieldDecl>(D)) { // If the alignment is less than or equal to 8 bits, the packed attribute // has no effect. - if (!FD->getType()->isIncompleteType() && + if (!FD->getType()->isDependentType() && + !FD->getType()->isIncompleteType() && S.Context.getTypeAlign(FD->getType()) <= 8) S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type) << Attr.getName() << FD->getType(); diff --git a/test/SemaTemplate/instantiate-attr.cpp b/test/SemaTemplate/instantiate-attr.cpp index 45136f6f60..1e94614f37 100644 --- a/test/SemaTemplate/instantiate-attr.cpp +++ b/test/SemaTemplate/instantiate-attr.cpp @@ -25,3 +25,12 @@ namespace test1 { int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1]; int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1]; } + +namespace test2 { + template <class type> + struct fastscriptmember { + type Member __attribute__ ((packed)); + char x; + }; + int test0[sizeof(fastscriptmember<int>) == 5 ? 1 : -1]; +} |