-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Concepts] Instantiate invented template type parameter type-constrai…
…nt along with function parameters We previously instantiated type-constraints of template type parameters along with the type parameter itself, this caused problems when the type-constraints created by abbreviated templates refreneced other parameters in the abbreviated templates. When encountering a template type parameter with a type constraint, if it is implicit, delay instantiation of the type-constraint until the function parameter which created the invented template type parameter is instantiated. Reland after fixing bug caused by another flow reaching SubstParmVarDecl and instantiating the TypeConstraint a second time. (cherry picked from commit 84959ae)
- Loading branch information
Showing
3 changed files
with
184 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
clang/test/SemaTemplate/instantiate-abbreviated-template.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify | ||
// expected-no-diagnostics | ||
|
||
template<typename...> | ||
concept C = true; | ||
|
||
template<typename T> | ||
struct S { | ||
template<typename U> | ||
static void foo1(U a, auto b); | ||
static void foo2(T a, C<T> auto b); | ||
static void foo3(T a, C<decltype(a)> auto b); | ||
static void foo4(T a, C<decltype(a)> auto b, const C<decltype(b)> auto &&c); | ||
}; | ||
|
||
using sf1 = decltype(S<int>::foo1(1, 2)); | ||
using sf2 = decltype(S<int>::foo2(1, 2)); | ||
using sf3 = decltype(S<int>::foo3(1, 2)); | ||
using sf4 = decltype(S<int>::foo4(1, 2, 3)); | ||
|
||
|
||
template<typename... T> | ||
struct G { | ||
static void foo1(auto a, const C<decltype(a)> auto &&... b); | ||
static void foo2(auto a, const C<decltype(a), T> auto &&... b); | ||
}; | ||
|
||
using gf1 = decltype(G<int, char>::foo1('a', 1, 2, 3, 4)); | ||
using gf2 = decltype(G<int, char>::foo2('a', 1, 2)); |