diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-02-10 02:02:21 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-02-10 02:02:21 +0000 |
commit | edb6f5dca102db69b932c98d51574db9ad4cd520 (patch) | |
tree | 33a1200d91ea4f2ab0fb9407fdf84dfd27be9236 /clang | |
parent | 9ef50bd66cbe18886958cfec560e4f4d680ad82a (diff) | |
download | bcm5719-llvm-edb6f5dca102db69b932c98d51574db9ad4cd520.tar.gz bcm5719-llvm-edb6f5dca102db69b932c98d51574db9ad4cd520.zip |
Make sure we convert struct layout pragmas to attributes for class templates the same way we do for non-template classes. <rdar://problem/10791194>.
llvm-svn: 150221
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaTemplate/pragma-ms_struct.cpp | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index ca34ada1324..af2c6efdff7 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1023,6 +1023,11 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, NumOuterTemplateParamLists, OuterTemplateParamLists); + // Add alignment attributes if necessary; these attributes are checked when + // the ASTContext lays out the structure. + AddAlignmentAttributesForRecord(NewClass); + AddMsStructLayoutForRecord(NewClass); + ClassTemplateDecl *NewTemplate = ClassTemplateDecl::Create(Context, SemanticContext, NameLoc, DeclarationName(Name), TemplateParams, diff --git a/clang/test/SemaTemplate/pragma-ms_struct.cpp b/clang/test/SemaTemplate/pragma-ms_struct.cpp new file mode 100644 index 00000000000..f04dc5ccae4 --- /dev/null +++ b/clang/test/SemaTemplate/pragma-ms_struct.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-osx10.7.0 %s + +#pragma ms_struct on + +// <rdar://problem/10791194> +template<int x> struct foo { + long long a; + int b; +}; +extern int arr[sizeof(foo<0>) == 16 ? 1 : -1]; |