]> granicus.if.org Git - clang/commitdiff
Make sure we convert struct layout pragmas to attributes for class templates the...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 10 Feb 2012 02:02:21 +0000 (02:02 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 10 Feb 2012 02:02:21 +0000 (02:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150221 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/pragma-ms_struct.cpp [new file with mode: 0644]

index ca34ada132436e64489767822334698f67e0d429..af2c6efdff71ca47fa886c219120d7db963ff3ce 100644 (file)
@@ -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/test/SemaTemplate/pragma-ms_struct.cpp b/test/SemaTemplate/pragma-ms_struct.cpp
new file mode 100644 (file)
index 0000000..f04dc5c
--- /dev/null
@@ -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];