[cfe-commits] r72401 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/align-x86.c
Eli Friedman
eli.friedman at gmail.com
Mon May 25 14:27:20 PDT 2009
Author: efriedma
Date: Mon May 25 16:27:19 2009
New Revision: 72401
URL: http://llvm.org/viewvc/llvm-project?rev=72401&view=rev
Log:
Extend getPreferredTypeAlign to handle _Complex double and long long
correctly.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/Sema/align-x86.c
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=72401&r1=72400&r2=72401&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon May 25 16:27:19 2009
@@ -563,11 +563,14 @@
/// a data type.
unsigned ASTContext::getPreferredTypeAlign(const Type *T) {
unsigned ABIAlign = getTypeAlign(T);
-
- // Doubles should be naturally aligned if possible.
- if (T->isSpecificBuiltinType(BuiltinType::Double))
- return std::max(ABIAlign, 64U);
-
+
+ // Double and long long should be naturally aligned if possible.
+ if (const ComplexType* CT = T->getAsComplexType())
+ T = CT->getElementType().getTypePtr();
+ if (T->isSpecificBuiltinType(BuiltinType::Double) ||
+ T->isSpecificBuiltinType(BuiltinType::LongLong))
+ return std::max(ABIAlign, (unsigned)getTypeSize(T));
+
return ABIAlign;
}
Modified: cfe/trunk/test/Sema/align-x86.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/align-x86.c?rev=72401&r1=72400&r2=72401&view=diff
==============================================================================
--- cfe/trunk/test/Sema/align-x86.c (original)
+++ cfe/trunk/test/Sema/align-x86.c Mon May 25 16:27:19 2009
@@ -3,4 +3,12 @@
// PR3433
double g1;
short chk1[__alignof__(g1) == 8 ? 1 : -1];
-short chk2[__alignof__(double) == 8 ? 1 : -1];
+short chk2[__alignof__(double) == 8 ? 1 : -1];
+
+long long g2;
+short chk1[__alignof__(g2) == 8 ? 1 : -1];
+short chk2[__alignof__(long long) == 8 ? 1 : -1];
+
+_Complex double g3;
+short chk1[__alignof__(g3) == 8 ? 1 : -1];
+short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];
More information about the cfe-commits
mailing list