From: Eli Friedman Date: Sun, 22 Feb 2009 03:31:23 +0000 (+0000) Subject: Fix for PR3433: map __alignof__ to preferred alignment. (This was X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c508203a278f6a9238fff46ae1f025b4b402b233;p=clang 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 e3c48091b5..103bc37f4f 100644 --- a/lib/AST/ExprConstant.cpp +++ b/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/test/Sema/align-x86.c b/test/Sema/align-x86.c new file mode 100644 index 0000000000..df392a2e1e --- /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 aa72566c89..e689c0eaeb 100644 --- a/test/Sema/attr-aligned.c +++ b/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]; -