]> granicus.if.org Git - clang/commit
Fix crash and rejects-valid when a later template parameter or default
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 20 Jun 2019 19:49:13 +0000 (19:49 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 20 Jun 2019 19:49:13 +0000 (19:49 +0000)
commit913a74de66db886e6a276d0644625e46cb549231
treeed6c1782744653147a67aba233394ad727024d1b
parenta24f44c96603aff88e235e5ea46285e84aeb85f5
Fix crash and rejects-valid when a later template parameter or default
template argument contains a backreference to a dependently-typed
earlier parameter.

In a case like:
  template<typename T, T A, decltype(A) = A> struct X {};
  template<typename U> auto Y = X<U, 0>();
we previously treated both references to `A` in the third parameter as
being of type `int` when checking the template-id in `Y`. That`s wrong;
the type of `A` in these contexts is the dependent type `U`.

When we encounter a non-type template argument that we can't convert to
the parameter type because of type-dependence, we now insert a dependent
conversion node so that the SubstNonTypeTemplateParmExpr for the
template argument will have the parameter's type rather than whatever
type the argument had.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363972 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ItaniumMangle.cpp
lib/Sema/Sema.cpp
lib/Sema/SemaTemplate.cpp
test/SemaTemplate/resolve-single-template-id.cpp
test/SemaTemplate/temp_arg_nontype.cpp