blob: 03ef78f8cf14e1704d615196194d2eacda41a926 [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 {};
Richard Smith43a833b2017-01-09 23:54:33 +000073 template<template<decltype(auto)> typename T> struct TDecltypeAuto {};
Richard Smith26b86ea2016-12-31 21:41:23 +000074 template<auto> struct Auto;
75 template<auto*> struct AutoPtr;
Richard Smith43a833b2017-01-09 23:54:33 +000076 template<decltype(auto)> struct DecltypeAuto;
Richard Smith26b86ea2016-12-31 21:41:23 +000077 template<int> struct Int;
78 template<int*> struct IntPtr;
79
80 TInt<Auto> ia;
Richard Smith13894182017-04-13 21:37:24 +000081 TInt<AutoPtr> iap; // FIXME: ill-formed (?)
Richard Smith957fbf12017-01-17 02:14:37 +000082 TInt<DecltypeAuto> ida;
Richard Smith26b86ea2016-12-31 21:41:23 +000083 TInt<Int> ii;
84 TInt<IntPtr> iip; // expected-error {{different template parameters}}
85
86 TIntPtr<Auto> ipa;
87 TIntPtr<AutoPtr> ipap;
Richard Smith957fbf12017-01-17 02:14:37 +000088 TIntPtr<DecltypeAuto> ipda;
Richard Smith26b86ea2016-12-31 21:41:23 +000089 TIntPtr<Int> ipi; // expected-error {{different template parameters}}
90 TIntPtr<IntPtr> ipip;
91
92 TAuto<Auto> aa;
Richard Smith13894182017-04-13 21:37:24 +000093 TAuto<AutoPtr> aap; // FIXME: ill-formed (?)
94 TAuto<Int> ai; // FIXME: ill-formed (?)
95 TAuto<IntPtr> aip; // FIXME: ill-formed (?)
Richard Smith26b86ea2016-12-31 21:41:23 +000096
97 TAutoPtr<Auto> apa;
98 TAutoPtr<AutoPtr> apap;
Richard Smith13894182017-04-13 21:37:24 +000099 TAutoPtr<Int> api; // FIXME: ill-formed (?)
100 TAutoPtr<IntPtr> apip; // FIXME: ill-formed (?)
Richard Smith43a833b2017-01-09 23:54:33 +0000101
102 TDecltypeAuto<DecltypeAuto> dada;
Richard Smith13894182017-04-13 21:37:24 +0000103 TDecltypeAuto<Int> dai; // FIXME: ill-formed (?)
104 TDecltypeAuto<IntPtr> daip; // FIXME: ill-formed (?)
Richard Smith43a833b2017-01-09 23:54:33 +0000105
Richard Smith4ae5ec82017-02-22 20:01:55 +0000106 // FIXME: It's completely unclear what should happen here, but these results
107 // seem at least plausible:
108 TAuto<DecltypeAuto> ada;
109 TAutoPtr<DecltypeAuto> apda;
110 // Perhaps this case should be invalid, as there are valid 'decltype(auto)'
111 // parameters (such as 'user-defined-type &') that are not valid 'auto'
112 // parameters.
Richard Smith43a833b2017-01-09 23:54:33 +0000113 TDecltypeAuto<Auto> daa;
Richard Smith13894182017-04-13 21:37:24 +0000114 TDecltypeAuto<AutoPtr> daap; // FIXME: should probably be ill-formed
Richard Smith26b86ea2016-12-31 21:41:23 +0000115
116 int n;
117 template<auto A, decltype(A) B = &n> struct SubstFailure;
Richard Smith957fbf12017-01-17 02:14:37 +0000118 TInt<SubstFailure> isf; // FIXME: this should be ill-formed
119 TIntPtr<SubstFailure> ipsf;
Richard Smith26b86ea2016-12-31 21:41:23 +0000120}