diff options
author | Saar Raz <saar@raz.email> | 2020-02-03 15:44:33 +0200 |
---|---|---|
committer | Saar Raz <saar@raz.email> | 2020-02-03 15:48:27 +0200 |
commit | 2b54b8b994b45d4e0a72f36dfb91dc9662543234 (patch) | |
tree | 126e920f83f7071886fe925c0450d58a32af1f9a /clang/test/SemaTemplate/instantiate-abbreviated-template.cpp | |
parent | 674ec1eb16678b8addc02a4b0534ab383d22fa77 (diff) | |
download | bcm5719-llvm-2b54b8b994b45d4e0a72f36dfb91dc9662543234.tar.gz bcm5719-llvm-2b54b8b994b45d4e0a72f36dfb91dc9662543234.zip |
[Concepts] Instantiate invented template type parameter type-constraint 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.
(cherry picked from commit eacca4824463d8b96e2e1c9f8bbf886055218a16)
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-abbreviated-template.cpp')
-rw-r--r-- | clang/test/SemaTemplate/instantiate-abbreviated-template.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp b/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp new file mode 100644 index 00000000000..a73b6ce3610 --- /dev/null +++ b/clang/test/SemaTemplate/instantiate-abbreviated-template.cpp @@ -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)); |