]> granicus.if.org Git - clang/commitdiff
Fix for PR3433: map __alignof__ to preferred alignment. (This was
authorEli Friedman <eli.friedman@gmail.com>
Sun, 22 Feb 2009 03:31:23 +0000 (03:31 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 22 Feb 2009 03:31:23 +0000 (03:31 +0000)
partially done in r65258.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65260 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/Sema/align-x86.c [new file with mode: 0644]
test/Sema/attr-aligned.c

index e3c48091b5e6d50c10ac97e9527372dae694d77f..103bc37f4fe88fdf1e3362e675b6d10e5cd6f1c3 100644 (file)
@@ -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 (file)
index 0000000..df392a2
--- /dev/null
@@ -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]; 
index aa72566c89fa0079a3f70413acf1142d7cb450c5..e689c0eaebea6b882966f163f90b8c80b57ac007 100644 (file)
@@ -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]; 
-