diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -173,7 +173,7 @@ *BaseInfo = LValueBaseInfo(AlignmentSource::Type); CharUnits Alignment; - if (T->isIncompleteType()) { + if (T->getBaseElementTypeUnsafe()->isIncompleteType()) { Alignment = CharUnits::One(); // Shouldn't be used, but pessimistic is best. } else { // For C++ class pointees, we don't know whether we're pointing at a diff --git a/clang/test/CodeGenCXX/alignment.cpp b/clang/test/CodeGenCXX/alignment.cpp --- a/clang/test/CodeGenCXX/alignment.cpp +++ b/clang/test/CodeGenCXX/alignment.cpp @@ -309,3 +309,7 @@ AlignedArray result = d.bArray; } } + +// CHECK-LABEL: @_Z22incomplete_array_derefPA_i +// CHECK: load i32, i32* {{%.*}}, align 4 +int incomplete_array_deref(int (*p)[]) { return (*p)[2]; }