diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5690,9 +5690,9 @@ // Find expected alignment, and the actual alignment of the passed object. // getTypeAlignInChars requires complete types - if (ArgTy.isNull() || ParamTy->isIncompleteType() || - ArgTy->isIncompleteType() || ParamTy->isUndeducedType() || - ArgTy->isUndeducedType()) + if (ArgTy.isNull() || ParamTy->isDependentType() || + ParamTy->isIncompleteType() || ArgTy->isIncompleteType() || + ParamTy->isUndeducedType() || ArgTy->isUndeducedType()) return; CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy); diff --git a/clang/test/SemaCXX/recovery-expr-type.cpp b/clang/test/SemaCXX/recovery-expr-type.cpp --- a/clang/test/SemaCXX/recovery-expr-type.cpp +++ b/clang/test/SemaCXX/recovery-expr-type.cpp @@ -162,3 +162,12 @@ b = __builtin_object_size(c, 0); // crash2 } } + +namespace test15 { +void f() { + struct { + void m(int (&)[undefined()]) {} // expected-error {{undeclared identifier}} + } S; + S.m(1); // no crash +} +}