Fix for PR3433: map __alignof__ to preferred alignment. (This was
partially done in r65258.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65260 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index e3c4809..103bc37 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -960,7 +960,7 @@
// Get information about the alignment.
unsigned CharSize = Info.Ctx.Target.getCharWidth();
- return Info.Ctx.getTypeAlign(Ty) / CharSize;
+ return Info.Ctx.getPreferredTypeAlign(Ty) / CharSize;
}
unsigned IntExprEvaluator::GetAlignOfExpr(const Expr *E) {
diff --git a/test/Sema/align-x86.c b/test/Sema/align-x86.c
new file mode 100644
index 0000000..df392a2
--- /dev/null
+++ b/test/Sema/align-x86.c
@@ -0,0 +1,6 @@
+// RUN: clang -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+// PR3433
+double g1;
+short chk1[__alignof__(g1) == 8 ? 1 : -1];
+short chk2[__alignof__(double) == 8 ? 1 : -1];
diff --git a/test/Sema/attr-aligned.c b/test/Sema/attr-aligned.c
index aa72566..e689c0e 100644
--- a/test/Sema/attr-aligned.c
+++ b/test/Sema/attr-aligned.c
@@ -5,8 +5,3 @@
// PR3254
short g0[3] __attribute__((aligned));
short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
-
-// PR3433
-double g1;
-short chk1[__alignof__(g1) == 8 ? 1 : -1];
-