[OpenACC] Enable 'attach' clause for combined constructs
[llvm-project.git] / clang / test / Parser / cxx2a-placeholder-type-constraint.cpp
blob8e61349ea8768c2054d9c5988f1abbc43e90af35
1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
3 template<typename T, typename U=void>
4 concept C = true;
6 namespace ns {
7 template<typename T, typename U=void>
8 concept D = true;
11 int foo() {
12 int I;
13 {ns::D auto a = 1;}
14 {C auto a = 1;}
15 {C<> auto a = 1;}
16 {C<int> auto a = 1;}
17 {ns::D<int> auto a = 1;}
18 {const ns::D auto &a = 1;}
19 {const C auto &a = 1;}
20 {const C<> auto &a = 1;}
21 {const C<int> auto &a = 1;}
22 {const ns::D<int> auto &a = 1;}
23 {C decltype(auto) a = 1;}
24 {C<> decltype(auto) a = 1;}
25 {C<int> decltype(auto) a = 1;}
26 {const C<> decltype(auto) &a = 1;} // expected-error{{'decltype(auto)' cannot be combined with other type specifiers}}
27 // expected-error@-1{{cannot form reference to 'decltype(auto)'}}
28 {const C<int> decltype(auto) &a = 1;} // expected-error{{'decltype(auto)' cannot be combined with other type specifiers}}
29 // expected-error@-1{{cannot form reference to 'decltype(auto)'}}
30 {C a = 1;}
31 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
32 {C const a2 = 1;}
33 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
34 {C &a3 = I;}
35 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
36 {C &&a4 = 1;}
37 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
38 {C decltype a19 = 1;}
39 // expected-error@-1{{expected '('}}
40 {C decltype(1) a20 = 1;}
41 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
44 void foo1(C auto &a){}
45 void foo2(C const &a){}
46 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
47 void foo3(C auto const &a){}
48 void foo4(const C &a){}
49 // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}}
51 namespace non_type {
52 template<int v>
53 concept C1 = true;
55 auto f() -> C1 auto {} // expected-error{{concept named in type constraint is not a type concept}}
56 auto g(C1 auto); // expected-error{{concept named in type constraint is not a type concept}}
57 C1 auto a = 0; // expected-error{{concept named in type constraint is not a type concept}}
58 C1 decltype(auto) b = 0; // expected-error{{concept named in type constraint is not a type concept}}
61 namespace arity {
62 template<typename v, typename>
63 concept C1 = true;
65 auto f() -> C1 auto {} // expected-error{{'C1' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}
66 auto g(C1 auto); // expected-error{{'C1' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}
67 C1 auto a = 0; // expected-error{{'C1' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}
68 C1 decltype(auto) b = 0; // expected-error{{'C1' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}