1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
2
3 namespace type
4 {
5 template<typename T>
6 concept C1 = true;
7
8 template<C1 T, C1 U = int>
9 using A = T[10];
10
11 using a = A<int>;
12
13 namespace ns {
14 template<typename T, int a = 0>
15 concept C2 = true;
16 }
17
18 template<ns::C2 T1, ::type::ns::C2 T2> requires (sizeof(T1) <= sizeof(T2))
19 struct B { };
20
21 using b = B<int, int>;
22
23 template<ns::C2... T1>
24 struct C { };
25
26 using c1 = C<char, char, char>;
27 using c2 = C<char, char, char, char>;
28 }
29
30 namespace non_type
31 {
32 template<int v>
33 concept C1 = true;
34
35 template<C1 v, C1 u = 0> // expected-error{{expected a type}} // expected-note{{declared here}}
36 // expected-error@-1 2{{concept named in type constraint is not a type concept}}
37 // expected-error@-2 {{expected ',' or '>' in template-parameter-list}}
38 int A = v; // expected-error{{'v' does not refer to a value}}
39 }
40
41 namespace temp
42 {
43 template<typename>
44 struct test1 { }; // expected-note{{template is declared here}}
45
46 template<template<typename> typename T>
47 concept C1 = true;
48
49 template<C1 TT, C1 UU = test1> // expected-error{{use of class template 'test1' requires template arguments}}
50 // expected-error@-1 2{{concept named in type constraint is not a type concept}}
51 using A = TT<int>; // expected-error{{expected ';' after alias declaration}}
52 }
53
54 namespace PR67235 {
55
56 template <class T>
57 concept C = true;
58
59 template <auto D>
60 struct S {};
61
62 // Don't destroy annotation 'C' at the end of the lambda; else we'll run into a
63 // use-after-free bug while constructing the type constraint 'C' on 'Default'.
64 template <typename Ret, C Default = decltype([] { return Ret(); })>
func()65 void func() {}
66
67 template <typename Ret, C Default = S<[] { return Ret(); }>>
func2()68 void func2() {}
69
70 }
71