diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index e331df86235b23..6bc202ecd5b021 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -12982,8 +12982,10 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X, SmallVector As; if (CD && getCommonTemplateArguments(Ctx, As, AX->getTypeConstraintArguments(), - AY->getTypeConstraintArguments())) + AY->getTypeConstraintArguments())) { CD = nullptr; // The arguments differ, so make it unconstrained. + As.clear(); + } // Both auto types can't be dependent, otherwise they wouldn't have been // sugar. This implies they can't contain unexpanded packs either. diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index e1686a7c69d522..c0d225034be892 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -4630,6 +4630,7 @@ AutoType::AutoType(QualType DeducedAsType, AutoTypeKeyword Keyword, AutoTypeBits.Keyword = (unsigned)Keyword; AutoTypeBits.NumArgs = TypeConstraintArgs.size(); this->TypeConstraintConcept = TypeConstraintConcept; + assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0); if (TypeConstraintConcept) { auto *ArgBuffer = const_cast(getTypeConstraintArguments().data());