|
1 | 1 | // RUN: %clang_cc1 %s -verify
|
2 |
| -// expected-no-diagnostics |
3 | 2 |
|
4 | 3 | template <typename...> struct TypeList;
|
5 | 4 |
|
@@ -28,6 +27,31 @@ static_assert(__is_same(Dependent<TypeList, int*, double*, int*>::twice, TypeLis
|
28 | 27 | static_assert(__is_same(Dependent<TypeList, int*, double*, int*>::dep_only_types, TypeList<int*, double*>));
|
29 | 28 | static_assert(__is_same(Dependent<TypeList, int*, double*, int*>::dep_only_template, TypeList<int, double>));
|
30 | 29 |
|
31 |
| -// FIXME: tests for using template type alias as a template |
32 |
| -// FIXME: tests for errors |
33 |
| -// FIXME: tests for locations |
| 30 | + |
| 31 | +template <class ...T> |
| 32 | +using Twice = TypeList<T..., T...>; |
| 33 | + |
| 34 | +static_assert(__is_same(__type_list_dedup<Twice, int, double, int>, TypeList<int, double, int, double>)); |
| 35 | + |
| 36 | + |
| 37 | +template <int...> struct IntList; |
| 38 | +// Wrong kinds of template arguments. |
| 39 | +__type_list_dedup<IntList>* wrong_template; // expected-error {{template template argument has different template parameters than its corresponding template template parameter}} |
| 40 | + // expected-note@-3 {{template parameter has a different kind in template argument}} |
| 41 | +__type_list_dedup<TypeList, 1, 2, 3>* wrong_template_args; // expected-error {{template argument for template type parameter must be a type}} |
| 42 | + // expected-note@* {{previous template template parameter is here}} |
| 43 | + // expected-note@* {{template parameter from hidden source}} |
| 44 | +__type_list_dedup<> not_enough_args; // expected-error {{too few template arguments for template '__type_list_dedup'}} |
| 45 | + // expected-note@* {{template declaration from hidden source}} |
| 46 | +__type_list_dedup missing_template_args; // expected-error {{use of template '__type_list_dedup' requires template arguments}} |
| 47 | + // expected-note@* {{template declaration from hidden source}} |
| 48 | + |
| 49 | +// Direct recursive use will fail because the signature of template parameters does not match. |
| 50 | +// The intention for this test is to anticipate a failure mode where compiler may start running the deduplication recursively, going into |
| 51 | +// an infinite loop without diagnosing an error. |
| 52 | +// Currently, the type checking prevents us from it, but if the builtin becomes more generic, we need to be aware of it. |
| 53 | +__type_list_dedup<__type_list_dedup, int, int, double>; // expected-error {{template template argument has different template parameters than its corresponding template template parameter}} |
| 54 | + // expected-note@* {{template parameter has a different kind in template argument}} |
| 55 | + // expected-note@* {{previous template template parameter is here}} |
| 56 | + |
| 57 | +// FIXME: tests for locations of template arguments, ideally we should point into the original locations of the template arguments. |
0 commit comments