Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 2 | |
| 3 | template<template<typename T> class X> struct A; // expected-note 2{{previous template template parameter is here}} |
| 4 | |
| 5 | template<template<typename T, int I> class X> struct B; // expected-note{{previous template template parameter is here}} |
| 6 | |
| 7 | template<template<int I> class X> struct C; // expected-note{{previous non-type template parameter with type 'int' is here}} |
| 8 | |
| 9 | template<class> struct X; // expected-note{{too few template parameters in template template argument}} |
| 10 | template<int N> struct Y; // expected-note{{template parameter has a different kind in template argument}} |
| 11 | template<long N> struct Ylong; // expected-note{{template non-type parameter has a different type 'long' in template argument}} |
| 12 | |
| 13 | namespace N { |
| 14 | template<class> struct Z; |
| 15 | } |
| 16 | template<class, class> struct TooMany; // expected-note{{too many template parameters in template template argument}} |
| 17 | |
| 18 | |
| 19 | A<X> *a1; |
| 20 | A<N::Z> *a2; |
| 21 | A< ::N::Z> *a3; |
| 22 | |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 23 | A<Y> *a4; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} |
| 24 | A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} |
| 25 | B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 26 | C<Y> *a7; |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 27 | C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 28 | |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 29 | template<typename T> void f(int); |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 30 | |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 31 | A<f> *a9; // expected-error{{must be a class template}} |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 32 | |
Richard Smith | ea698b3 | 2011-04-14 21:45:45 +0000 | [diff] [blame] | 33 | // Evil digraph '<:' is parsed as '[', expect error. |
| 34 | A<::N::Z> *a10; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} |
| 35 | |
| 36 | // Do not do a digraph correction here. |
| 37 | A<: :N::Z> *a11; // expected-error{{expected expression}} \ |
| 38 | expected-error{{C++ requires a type specifier for all declarations}} |
Douglas Gregor | caadc12 | 2010-08-06 14:15:26 +0000 | [diff] [blame] | 39 | |
| 40 | // PR7807 |
| 41 | namespace N { |
| 42 | template <typename, typename = int> |
| 43 | struct X |
| 44 | { }; |
| 45 | |
| 46 | template <typename ,int> |
| 47 | struct Y |
| 48 | { X<int> const_ref(); }; |
| 49 | |
| 50 | template <template<typename,int> class TT, typename T, int N> |
| 51 | int operator<<(int, TT<T, N> a) { // expected-note{{candidate template ignored}} |
| 52 | 0 << a.const_ref(); // expected-error{{invalid operands to binary expression ('int' and 'X<int>')}} |
| 53 | } |
| 54 | |
| 55 | void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<Y, int, 1>' requested here}} |
| 56 | } |