diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index dc22481d0a84..7e435e8b35b8 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1088,6 +1088,9 @@ class TemplateDiff { Ty->getAs()) return TST; + if (const auto* SubstType = Ty->getAs()) + Ty = SubstType->getReplacementType(); + const RecordType *RT = Ty->getAs(); if (!RT) diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp index cc1cc9ca7067..6bf6e2de4277 100644 --- a/clang/test/Misc/diag-template-diffing.cpp +++ b/clang/test/Misc/diag-template-diffing.cpp @@ -1488,6 +1488,43 @@ void run(A_reg reg, A_ptr ptr, A_ref ref) { } } +namespace SubstTemplateTypeParmType { +template +class Array { +}; + +template +class S{}; + +template +Array Make(T (¶meter)[num]); + +void Run(int, Array>) {} + +Array> Make(); +void Call() { + const S s1[5]; + S s2[5]; + + Run(0, Make(s1)); // Error + Run(0, Make(s2)); // Okay +} + +// CHECK-ELIDE-NOTREE: no matching function for call to 'Run' +// CHECK-ELIDE-NOTREE: no known conversion from 'Array>' to 'Array>' for 2nd argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'Run' +// CHECK-NOELIDE-NOTREE: no known conversion from 'Array>' to 'Array>' for 2nd argument +// CHECK-ELIDE-TREE: no matching function for call to 'Run' +// CHECK-ELIDE-TREE: no known conversion from argument type to parameter type for 2nd argument +// CHECK-ELIDE-TREE: Array< +// CHECK-ELIDE-TREE: [const != (no qualifiers)] S<...>> +// CHECK-NOELIDE-TREE: no matching function for call to 'Run' +// CHECK-NOELIDE-TREE: no known conversion from argument type to parameter type for 2nd argument +// CHECK-NOELIDE-TREE: Array< +// CHECK-NOELIDE-TREE: [const != (no qualifiers)] S< +// CHECK-NOELIDE-TREE: int>> +} + // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.