Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 2 | |
| 3 | namespace N { |
| 4 | namespace M { |
Chris Lattner | f4382f5 | 2009-04-14 22:17:06 +0000 | [diff] [blame] | 5 | template<typename T> struct Promote; |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 6 | |
| 7 | template<> struct Promote<short> { |
| 8 | typedef int type; |
| 9 | }; |
| 10 | |
| 11 | template<> struct Promote<int> { |
| 12 | typedef int type; |
| 13 | }; |
| 14 | |
| 15 | template<> struct Promote<float> { |
| 16 | typedef double type; |
| 17 | }; |
| 18 | |
| 19 | Promote<short>::type *ret_intptr(int* ip) { return ip; } |
| 20 | Promote<int>::type *ret_intptr2(int* ip) { return ip; } |
| 21 | } |
| 22 | |
| 23 | M::Promote<int>::type *ret_intptr3(int* ip) { return ip; } |
Douglas Gregor | 1a15dae | 2010-06-16 22:31:08 +0000 | [diff] [blame] | 24 | M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' keyword outside of a template}} |
Douglas Gregor | d6ab232 | 2010-06-16 23:00:59 +0000 | [diff] [blame] | 25 | M::template Promote<int> pi; // expected-warning{{'template' keyword outside of a template}} |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; } |
| 29 | ::N::M::Promote<int>::type *ret_intptr6(int* ip) { return ip; } |
| 30 | |
| 31 | |
Douglas Gregor | 7bb87fc | 2009-11-11 16:39:34 +0000 | [diff] [blame] | 32 | N::M::template; // expected-error{{expected unqualified-id}} |
| 33 | N::M::template Promote; // expected-error{{expected unqualified-id}} |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 34 | |
| 35 | namespace N { |
| 36 | template<typename T> struct A; |
| 37 | |
| 38 | template<> |
| 39 | struct A<int> { |
| 40 | struct X; |
| 41 | }; |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 42 | |
| 43 | struct B; |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | struct ::N::A<int>::X { |
| 47 | int foo; |
| 48 | }; |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 49 | |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 50 | template<typename T> |
| 51 | struct TestA { |
Douglas Gregor | 7bb87fc | 2009-11-11 16:39:34 +0000 | [diff] [blame] | 52 | typedef typename N::template B<T>::type type; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \ |
Douglas Gregor | 7bb87fc | 2009-11-11 16:39:34 +0000 | [diff] [blame] | 53 | // expected-error{{expected member name}} |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 54 | }; |
John McCall | 63b4385 | 2010-04-29 23:50:39 +0000 | [diff] [blame] | 55 | |
| 56 | // Reduced from a Boost failure. |
| 57 | namespace test1 { |
| 58 | template <class T> struct pair { |
| 59 | T x; |
| 60 | T y; |
| 61 | |
| 62 | static T pair<T>::* const mem_array[2]; |
| 63 | }; |
| 64 | |
| 65 | template <class T> |
| 66 | T pair<T>::* const pair<T>::mem_array[2] = { &pair<T>::x, &pair<T>::y }; |
| 67 | } |
Douglas Gregor | 00b4b03 | 2010-05-14 04:53:42 +0000 | [diff] [blame] | 68 | |
| 69 | typedef int T; |
| 70 | namespace N1 { |
| 71 | template<typename T> T f0(); |
| 72 | } |
| 73 | |
| 74 | template<typename T> T N1::f0() { } |
Douglas Gregor | e2872d0 | 2010-06-17 16:03:49 +0000 | [diff] [blame^] | 75 | |
| 76 | namespace PR7385 { |
| 77 | template< typename > struct has_xxx0 |
| 78 | { |
| 79 | template< typename > struct has_xxx0_introspect |
| 80 | { |
| 81 | template< typename > struct has_xxx0_substitute ; |
| 82 | template< typename V > |
| 83 | int int00( has_xxx0_substitute < typename V::template xxx< > > = 0 ); |
| 84 | }; |
| 85 | static const int value = has_xxx0_introspect<int>::value; // expected-error{{no member named 'value'}} |
| 86 | typedef int type; |
| 87 | }; |
| 88 | |
| 89 | has_xxx0<int>::type t; // expected-note{{instantiation of}} |
| 90 | } |