[cfe-commits] r150221 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/pragma-ms_struct.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Feb 9 18:02:21 PST 2012
Author: efriedma
Date: Thu Feb 9 20:02:21 2012
New Revision: 150221
URL: http://llvm.org/viewvc/llvm-project?rev=150221&view=rev
Log:
Make sure we convert struct layout pragmas to attributes for class templates the same way we do for non-template classes. <rdar://problem/10791194>.
Added:
cfe/trunk/test/SemaTemplate/pragma-ms_struct.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=150221&r1=150220&r2=150221&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Feb 9 20:02:21 2012
@@ -1023,6 +1023,11 @@
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,
Added: cfe/trunk/test/SemaTemplate/pragma-ms_struct.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/pragma-ms_struct.cpp?rev=150221&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/pragma-ms_struct.cpp (added)
+++ cfe/trunk/test/SemaTemplate/pragma-ms_struct.cpp Thu Feb 9 20:02:21 2012
@@ -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];
More information about the cfe-commits
mailing list