diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index d17ca780fc..5b0664101f 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1264,9 +1264,13 @@ unsigned CodeGenFunction::GetPointeeAlignment(const Expr *Addr) { // Check if the type is a pointer. The implicit cast operand might not be. while (Addr->getType()->isPointerType()) { QualType PtTy = Addr->getType()->getPointeeType(); - unsigned NewA = getContext().getTypeAlignInChars(PtTy).getQuantity(); - if (NewA > Align) - Align = NewA; + + // Can't get alignment of incomplete types. + if (!PtTy->isIncompleteType()) { + unsigned NewA = getContext().getTypeAlignInChars(PtTy).getQuantity(); + if (NewA > Align) + Align = NewA; + } // If the address is an implicit cast, repeat with the cast operand. if (const ImplicitCastExpr *CastAddr = dyn_cast<ImplicitCastExpr>(Addr)) { |