From: David Majnemer Date: Tue, 3 Feb 2015 07:35:55 +0000 (+0000) Subject: MS ABI: Records with required alignment can't have common linkage X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98347f896369871f3baf612138e2899d9b6fe9c1;p=clang MS ABI: Records with required alignment can't have common linkage This fixes PR22441. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227950 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c72c239320..57f82ed7ce 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1685,6 +1685,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl()); Width = toBits(Layout.getSize()); Align = toBits(Layout.getAlignment()); + AlignIsRequired = RT->getDecl()->hasAttr(); break; } diff --git a/test/CodeGen/ms-align-tentative.c b/test/CodeGen/ms-align-tentative.c index ccd7616164..13d7440e88 100644 --- a/test/CodeGen/ms-align-tentative.c +++ b/test/CodeGen/ms-align-tentative.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -fms-compatibility -o - < %s | FileCheck %s char __declspec(align(8192)) x; // CHECK-DAG: @x = global i8 0, align 8192 @@ -13,3 +13,8 @@ T __declspec(align(8192)) z; int __declspec(align(16)) redef; int __declspec(align(32)) redef = 8; // CHECK-DAG: @redef = global i32 8, align 32 + +struct __declspec(align(64)) S { + char fd; +} s; +// CHECK-DAG: @s = global %struct.S zeroinitializer, align 64