Douglas Gregor | 5d290d5 | 2009-02-10 17:43:50 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | class X; |
| 4 | |
| 5 | // C++ [temp.param]p4 |
| 6 | typedef int INT; |
| 7 | enum E { enum1, enum2 }; |
| 8 | template<int N> struct A1; |
| 9 | template<INT N, INT M> struct A2; |
| 10 | template<enum E x, E y> struct A3; |
| 11 | template<int &X> struct A4; |
| 12 | template<int *Ptr> struct A5; |
| 13 | template<int (&f)(int, int)> struct A6; |
| 14 | template<int (*fp)(float, double)> struct A7; |
| 15 | template<int X::*pm> struct A8; |
| 16 | template<float (X::*pmf)(float, int)> struct A9; |
| 17 | template<typename T, T x> struct A10; |
| 18 | |
| 19 | template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} |
| 20 | |
Douglas Gregor | a35284b | 2009-02-11 00:19:33 +0000 | [diff] [blame] | 21 | template<void *Ptr> struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}} |
Douglas Gregor | 5d290d5 | 2009-02-10 17:43:50 +0000 | [diff] [blame] | 22 | |
| 23 | // C++ [temp.param]p8 |
| 24 | template<int X[10]> struct A5; |
| 25 | template<int f(float, double)> struct A7; |
| 26 | |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 27 | // C++ [temp.param]p11: |
| 28 | template<typename> struct Y1; // expected-note{{too few template parameters in template template argument}} |
| 29 | template<typename, int> struct Y2; |
Douglas Gregor | 5d290d5 | 2009-02-10 17:43:50 +0000 | [diff] [blame] | 30 | |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 31 | template<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 Gregor | 5d290d5 | 2009-02-10 17:43:50 +0000 | [diff] [blame] | 34 | |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 35 | template<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 | |
| 39 | template<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 Gregor | 68c6993 | 2009-02-10 19:52:54 +0000 | [diff] [blame] | 43 | // Check for bogus template parameter shadow warning. |
| 44 | template<template<class T> class, |
| 45 | template<class T> class> |
| 46 | class B1noshadow; |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 47 | |
| 48 | // C++ [temp.param]p10: |
| 49 | template<class T1, class T2 = int> class B2; |
| 50 | template<class T1 = int, class T2> class B2; |
| 51 | |
| 52 | template<template<class, int> class, template<class> class = Y1> class B2t; |
| 53 | template<template<class, int> class = Y2, template<class> class> class B2t; |
| 54 | |
| 55 | template<int N, int M = 5> class B2n; |
| 56 | template<int N = 5, int M> class B2n; |
| 57 | |
| 58 | // C++ [temp.param]p12: |
| 59 | template<class T1, |
| 60 | class T2 = int> // expected-note{{previous default template argument defined here}} |
| 61 | class B3; |
| 62 | template<class T1, typename T2> class B3; |
| 63 | template<class T1, |
| 64 | typename T2 = float> // expected-error{{template parameter redefines default argument}} |
| 65 | class B3; |
| 66 | |
| 67 | template<template<class, int> class, |
| 68 | template<class> class = Y1> // expected-note{{previous default template argument defined here}} |
| 69 | class B3t; |
| 70 | |
| 71 | template<template<class, int> class, template<class> class> class B3t; |
| 72 | |
| 73 | template<template<class, int> class, |
| 74 | template<class> class = Y1> // expected-error{{template parameter redefines default argument}} |
| 75 | class B3t; |
| 76 | |
| 77 | template<int N, |
| 78 | int M = 5> // expected-note{{previous default template argument defined here}} |
| 79 | class B3n; |
| 80 | |
| 81 | template<int N, int M> class B3n; |
| 82 | |
| 83 | template<int N, |
| 84 | int M = 7> // expected-error{{template parameter redefines default argument}} |
| 85 | class B3n; |
| 86 | |
| 87 | // Check validity of default arguments |
| 88 | template<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; |