xref: /llvm-project/clang/test/Parser/cxx-template-template-recovery.cpp (revision 9c4a716c1292096fcbdf415b63b7b0122b03310f)
1 // RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only %s
2 
3 namespace a {
4   template <typename T>
5   concept C1 = true; // #C1
6 
7   template <typename T>
8   auto V1 = true; // #V1
9 
10   namespace b {
11     template <typename T>
12     concept C2 = true; // #C2
13     template <typename T>
14     auto V2 = true; // #V2
15   }
16 }
17 
18 template <typename T>
19 concept C3 = true; // #C3
20 template <typename T>
21 auto V3 = true; // #V3
22 template <template <typename T> typename C>
23 constexpr bool test = true;
24 
25 static_assert(test<a::C1>); // expected-error {{too few template arguments for concept 'C1'}} \
26                             // expected-note@#C1 {{here}}
27 static_assert(test<a::b::C2>); // expected-error {{too few template arguments for concept 'C2'}} \
28                                // expected-note@#C2 {{here}}
29 static_assert(test<C3>); // expected-error {{too few template arguments for concept 'C3'}} \
30                          // expected-note@#C3 {{here}}
31 
32 static_assert(test<a::V1>); // expected-error {{use of variable template 'a::V1' requires template arguments}} \
33                             // expected-note@#V1 {{here}}
34 static_assert(test<a::b::V2>); // expected-error {{use of variable template 'a::b::V2' requires template arguments}} \
35                             // expected-note@#V2 {{here}}
36 static_assert(test<V3>); // expected-error {{use of variable template 'V3' requires template arguments}} \
37                          // expected-note@#V3 {{here}}
38 
39 
f()40 void f() {
41     C3 t1 = 0;  // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}}
42     a::C1 t2 = 0; // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}}
43     a::b::C2 t3 = 0; // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}}
44 }
45