blob: 1f10cc49c10281cc03e9349f39583695dc7ab4c5 [file] [log] [blame]
Douglas Gregor5d290d52009-02-10 17:43:50 +00001// RUN: clang -fsyntax-only -verify %s
2
3class X;
4
5// C++ [temp.param]p4
6typedef int INT;
7enum E { enum1, enum2 };
8template<int N> struct A1;
9template<INT N, INT M> struct A2;
10template<enum E x, E y> struct A3;
11template<int &X> struct A4;
12template<int *Ptr> struct A5;
13template<int (&f)(int, int)> struct A6;
14template<int (*fp)(float, double)> struct A7;
15template<int X::*pm> struct A8;
16template<float (X::*pmf)(float, int)> struct A9;
17template<typename T, T x> struct A10;
18
19template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}}
20
Douglas Gregora35284b2009-02-11 00:19:33 +000021template<void *Ptr> struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}}
Douglas Gregor5d290d52009-02-10 17:43:50 +000022
23// C++ [temp.param]p8
24template<int X[10]> struct A5;
25template<int f(float, double)> struct A7;
26
Douglas Gregord684b002009-02-10 19:49:53 +000027// C++ [temp.param]p11:
28template<typename> struct Y1; // expected-note{{too few template parameters in template template argument}}
29template<typename, int> struct Y2;
Douglas Gregor5d290d52009-02-10 17:43:50 +000030
Douglas Gregord684b002009-02-10 19:49:53 +000031template<class T1 = int, // expected-note{{previous default template argument defined here}}
32 class T2> // expected-error{{template parameter missing a default argument}}
33 class B1;
Douglas Gregor5d290d52009-02-10 17:43:50 +000034
Douglas Gregord684b002009-02-10 19:49:53 +000035template<template<class> class = Y1, // expected-note{{previous default template argument defined here}}
36 template<class> class> // expected-error{{template parameter missing a default argument}}
37 class B1t;
38
39template<int N = 5, // expected-note{{previous default template argument defined here}}
40 int M> // expected-error{{template parameter missing a default argument}}
41 class B1n;
42
Douglas Gregor68c69932009-02-10 19:52:54 +000043// Check for bogus template parameter shadow warning.
44template<template<class T> class,
45 template<class T> class>
46 class B1noshadow;
Douglas Gregord684b002009-02-10 19:49:53 +000047
48// C++ [temp.param]p10:
49template<class T1, class T2 = int> class B2;
50template<class T1 = int, class T2> class B2;
51
52template<template<class, int> class, template<class> class = Y1> class B2t;
53template<template<class, int> class = Y2, template<class> class> class B2t;
54
55template<int N, int M = 5> class B2n;
56template<int N = 5, int M> class B2n;
57
58// C++ [temp.param]p12:
59template<class T1,
60 class T2 = int> // expected-note{{previous default template argument defined here}}
61 class B3;
62template<class T1, typename T2> class B3;
63template<class T1,
64 typename T2 = float> // expected-error{{template parameter redefines default argument}}
65 class B3;
66
67template<template<class, int> class,
68 template<class> class = Y1> // expected-note{{previous default template argument defined here}}
69 class B3t;
70
71template<template<class, int> class, template<class> class> class B3t;
72
73template<template<class, int> class,
74 template<class> class = Y1> // expected-error{{template parameter redefines default argument}}
75 class B3t;
76
77template<int N,
78 int M = 5> // expected-note{{previous default template argument defined here}}
79 class B3n;
80
81template<int N, int M> class B3n;
82
83template<int N,
84 int M = 7> // expected-error{{template parameter redefines default argument}}
85 class B3n;
86
87// Check validity of default arguments
88template<template<class, int> class // expected-note{{previous template template parameter is here}}
89 = Y1> // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
90 class C1;