Perhaps the test case could be stripped down a bit? template <typename T> class Array {};
template <class T> class S {}; template <class T> Array<T> Make(); void Call() { Array<S<int>> v = Make<const S<int>>(); } Seems to exhibit the same issue, by the looks of it. On Mon, Aug 16, 2021 at 6:38 PM via cfe-commits <cfe-commits@lists.llvm.org> wrote: > > Author: Weverything > Date: 2021-08-16T18:34:18-07:00 > New Revision: c411c1bd7f7d3550d24333f80980c0be6481d34a > > URL: > https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a > DIFF: > https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a.diff > > LOG: Fix missing qualifier in template type diffing > > Handle SubstTemplateTypeParmType so qualifiers do not get dropped from > the diagnostic message. > > Added: > > > Modified: > clang/lib/AST/ASTDiagnostic.cpp > clang/test/Misc/diag-template-diffing.cpp > > Removed: > > > > > ################################################################################ > diff --git a/clang/lib/AST/ASTDiagnostic.cpp > b/clang/lib/AST/ASTDiagnostic.cpp > index dc22481d0a84c..7e435e8b35b80 100644 > --- a/clang/lib/AST/ASTDiagnostic.cpp > +++ b/clang/lib/AST/ASTDiagnostic.cpp > @@ -1088,6 +1088,9 @@ class TemplateDiff { > Ty->getAs<TemplateSpecializationType>()) > return TST; > > + if (const auto* SubstType = Ty->getAs<SubstTemplateTypeParmType>()) > + Ty = SubstType->getReplacementType(); > + > const RecordType *RT = Ty->getAs<RecordType>(); > > if (!RT) > > diff --git a/clang/test/Misc/diag-template- > diff ing.cpp b/clang/test/Misc/diag-template- > diff ing.cpp > index cc1cc9ca70679..6bf6e2de4277c 100644 > --- a/clang/test/Misc/diag-template- > diff ing.cpp > +++ b/clang/test/Misc/diag-template- > diff ing.cpp > @@ -1488,6 +1488,43 @@ void run(A_reg<float> reg, A_ptr<float> ptr, > A_ref<float> ref) { > } > } > > +namespace SubstTemplateTypeParmType { > +template <typename T> > +class Array { > +}; > + > +template <class T> > +class S{}; > + > +template <class T, int num> > +Array<T> Make(T (¶meter)[num]); > + > +void Run(int, Array<S<int>>) {} > + > +Array<const S<int>> Make(); > +void Call() { > + const S<int> s1[5]; > + S<int> 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<const S<...>>' to > 'Array<S<...>>' for 2nd argument > +// CHECK-NOELIDE-NOTREE: no matching function for call to 'Run' > +// CHECK-NOELIDE-NOTREE: no known conversion from 'Array<const S<int>>' > to 'Array<S<int>>' 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. > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits