diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -4369,14 +4369,19 @@ CallExpr::const_arg_iterator Arg = ArgRange.begin(); for (QualType Ty : ArgTypes) { assert(Arg != ArgRange.end() && "Running over edge of argument list!"); - assert( - (isGenericMethod || Ty->isVariablyModifiedType() || - Ty.getNonReferenceType()->isObjCRetainableType() || - getContext() - .getCanonicalType(Ty.getNonReferenceType()) - .getTypePtr() == - getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) && - "type mismatch in call argument!"); + // argument can be ConstantArrayType and parameter can be IncompleteArrayType + const Type *CanonicalTy = getContext() + .getCanonicalType(Ty.getNonReferenceType()) + .getTypePtr() + ->getPointeeOrArrayElementType(); + const Type *CanonicalArgTy = getContext() + .getCanonicalType((*Arg)->getType()) + .getTypePtr() + ->getPointeeOrArrayElementType(); + assert((isGenericMethod || Ty->isVariablyModifiedType() || + Ty.getNonReferenceType()->isObjCRetainableType() || + CanonicalTy == CanonicalArgTy) && + "type mismatch in call argument!"); ++Arg; } diff --git a/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp b/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp --- a/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp +++ b/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp @@ -23,4 +23,13 @@ return r2; } + +// CHECK-LABEL: @_ZN3One3fooEi +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +void foo(int a) { + auto f = [](int(&&)[]) {}; + f({a}); +} + } // namespace One