diff options
author | Chris Lattner <sabre@nondot.org> | 2012-03-04 00:52:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2012-03-04 00:52:12 +0000 |
commit | d6e73569ccf09369f9bd2021d53c88e7bded06e3 (patch) | |
tree | 33308283dc27a2f3292516776f3d9a1682bbe1ca /lib/CodeGen/CGBuiltin.cpp | |
parent | ec92bc78979aae6ec436fe51d082f7467e6f96c0 (diff) |
add a testcase for PR12094 and fix a crash on pointer to incomplete type,
reported by Richard Smith.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151993 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-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)) { |