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 | aaa18fad7d7dce440b0bef11d967a5d602730c8d (patch) | |
| tree | cc7d2810ece36ac7bd9954643e3be7d6fc027b21 /clang/lib | |
| parent | 522fa537033d94bf1ea500e9eb5ec743f702bd36 (diff) | |
| download | bcm5719-llvm-aaa18fad7d7dce440b0bef11d967a5d602730c8d.tar.gz bcm5719-llvm-aaa18fad7d7dce440b0bef11d967a5d602730c8d.zip | |
add a testcase for PR12094 and fix a crash on pointer to incomplete type,
reported by Richard Smith.
llvm-svn: 151993
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index d17ca780fce..5b0664101f0 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/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)) { |

