From: Eli Friedman Date: Wed, 7 Nov 2012 00:35:20 +0000 (+0000) Subject: Add missing check to warning for packed attribute. PR14259. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c087c3f6c5c63dc543b2f2c29e72af16353231fb;p=platform%2Fupstream%2Fllvm.git Add missing check to warning for packed attribute. PR14259. llvm-svn: 167510 --- diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 6db30be..aef87c6 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -963,7 +963,8 @@ static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &Attr) { else if (FieldDecl *FD = dyn_cast(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/clang/test/SemaTemplate/instantiate-attr.cpp b/clang/test/SemaTemplate/instantiate-attr.cpp index 45136f6..1e94614 100644 --- a/clang/test/SemaTemplate/instantiate-attr.cpp +++ b/clang/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 + struct fastscriptmember { + type Member __attribute__ ((packed)); + char x; + }; + int test0[sizeof(fastscriptmember) == 5 ? 1 : -1]; +}