From 3f8c01a11029a0c7122426e93c1f9103c60aead3 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 22 Feb 2009 03:31:23 +0000 Subject: Fix for PR3433: map __alignof__ to preferred alignment. (This was partially done in r65258.) llvm-svn: 65260 --- clang/lib/AST/ExprConstant.cpp | 2 +- clang/test/Sema/align-x86.c | 6 ++++++ clang/test/Sema/attr-aligned.c | 5 ----- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 clang/test/Sema/align-x86.c (limited to 'clang') diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index e3c48091b5e..103bc37f4fe 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -960,7 +960,7 @@ unsigned IntExprEvaluator::GetAlignOfType(QualType T) { // 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/clang/test/Sema/align-x86.c b/clang/test/Sema/align-x86.c new file mode 100644 index 00000000000..df392a2e1e8 --- /dev/null +++ b/clang/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/clang/test/Sema/attr-aligned.c b/clang/test/Sema/attr-aligned.c index aa72566c89f..e689c0eaebe 100644 --- a/clang/test/Sema/attr-aligned.c +++ b/clang/test/Sema/attr-aligned.c @@ -5,8 +5,3 @@ int x __attribute__((aligned(3))); // expected-error {{requested alignment is no // PR3254 short g0[3] __attribute__((aligned)); short g0_chk[__alignof__(g0) == 16 ? 1 : -1]; - -// PR3433 -double g1; -short chk1[__alignof__(g1) == 8 ? 1 : -1]; - -- cgit v1.2.3