blob: b6b283b53c6be3dddde307b3e08b5d94ac11778e [file] [log] [blame]
Richard Smith26b86ea2016-12-31 21:41:23 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -frelaxed-template-template-args %s
2
3// expected-note@temp_arg_template_cxx1z.cpp:* 1+{{}}
4
5template<template<int> typename> struct Ti;
6template<template<int...> typename> struct TPi;
7template<template<int, int...> typename> struct TiPi;
8template<template<int..., int...> typename> struct TPiPi; // FIXME: Why is this not ill-formed?
9
10template<typename T, template<T> typename> struct tT0;
11template<template<typename T, T> typename> struct Tt0;
12
13template<template<typename> typename> struct Tt;
14template<template<typename, typename...> typename> struct TtPt;
15
16template<int> struct i;
17template<int, int = 0> struct iDi;
18template<int, int> struct ii;
19template<int...> struct Pi;
20template<int, int, int...> struct iiPi;
21
22template<int, typename = int> struct iDt;
23template<int, typename> struct it;
24
25template<typename T, T v> struct t0;
26
27template<typename...> struct Pt;
28
29namespace IntParam {
30 using ok = Pt<Ti<i>,
31 Ti<iDi>,
32 Ti<Pi>,
33 Ti<iDt>>;
34 using err1 = Ti<ii>; // expected-error {{different template parameters}}
35 using err2 = Ti<iiPi>; // expected-error {{different template parameters}}
36 using err3 = Ti<t0>; // expected-error {{different template parameters}}
37 using err4 = Ti<it>; // expected-error {{different template parameters}}
38}
39
40// These are accepted by the backwards-compatibility "parameter pack in
41// parameter matches any number of parameters in arguments" rule.
42namespace IntPackParam {
43 using ok = TPi<Pi>;
44 using ok_compat = Pt<TPi<i>, TPi<iDi>, TPi<ii>, TPi<iiPi>>;
45 using err1 = TPi<t0>; // expected-error {{different template parameters}}
46 using err2 = TPi<iDt>; // expected-error {{different template parameters}}
47 using err3 = TPi<it>; // expected-error {{different template parameters}}
48}
49
50namespace IntAndPackParam {
51 using ok = TiPi<Pi>;
52 using ok_compat = Pt<TiPi<ii>, TiPi<iDi>, TiPi<iiPi>>;
53 using err = TiPi<iDi>;
54}
55
56namespace DependentType {
57 using ok = Pt<tT0<int, i>, tT0<int, iDi>>;
58 using err1 = tT0<int, ii>; // expected-error {{different template parameters}}
59 using err2 = tT0<short, i>; // FIXME: should this be OK?
60 using err2a = tT0<long long, i>; // FIXME: should this be OK (if long long is larger than int)?
61 using err2b = tT0<void*, i>; // expected-error {{different template parameters}}
62 using err3 = tT0<short, t0>; // expected-error {{different template parameters}}
63
64 using ok2 = Tt0<t0>;
65 using err4 = Tt0<it>; // expected-error {{different template parameters}}
66}
67
68namespace Auto {
69 template<template<int> typename T> struct TInt {};
70 template<template<int*> typename T> struct TIntPtr {};
71 template<template<auto> typename T> struct TAuto {};
72 template<template<auto*> typename T> struct TAutoPtr {};
73 template<auto> struct Auto;
74 template<auto*> struct AutoPtr;
75 template<int> struct Int;
76 template<int*> struct IntPtr;
77
78 TInt<Auto> ia;
79 TInt<AutoPtr> iap; // FIXME: ill-formed
80 TInt<Int> ii;
81 TInt<IntPtr> iip; // expected-error {{different template parameters}}
82
83 TIntPtr<Auto> ipa;
84 TIntPtr<AutoPtr> ipap;
85 TIntPtr<Int> ipi; // expected-error {{different template parameters}}
86 TIntPtr<IntPtr> ipip;
87
88 TAuto<Auto> aa;
89 TAuto<AutoPtr> aap; // FIXME: ill-formed
90 TAuto<Int> ai; // FIXME: ill-formed
91 TAuto<IntPtr> aip; // FIXME: ill-formed
92
93 TAutoPtr<Auto> apa;
94 TAutoPtr<AutoPtr> apap;
95 TAutoPtr<Int> api; // FIXME: ill-formed
96 TAutoPtr<IntPtr> apip; // FIXME: ill-formed
97
98 int n;
99 template<auto A, decltype(A) B = &n> struct SubstFailure;
100 TInt<SubstFailure> isf; // expected-error {{different template parameters}}
101 TIntPtr<SubstFailure> ipsf; // expected-error {{different template parameters}}
102}