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 | 732281d | 2010-06-14 22:07:54 +0000 | [diff] [blame^] | 24 | M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' refers to a non-dependent template name; accepted as a C++0x extension}} |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; } |
| 28 | ::N::M::Promote<int>::type *ret_intptr6(int* ip) { return ip; } |
| 29 | |
| 30 | |
Douglas Gregor | 7bb87fc | 2009-11-11 16:39:34 +0000 | [diff] [blame] | 31 | N::M::template; // expected-error{{expected unqualified-id}} |
| 32 | N::M::template Promote; // expected-error{{expected unqualified-id}} |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 33 | |
| 34 | namespace N { |
| 35 | template<typename T> struct A; |
| 36 | |
| 37 | template<> |
| 38 | struct A<int> { |
| 39 | struct X; |
| 40 | }; |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 41 | |
| 42 | struct B; |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | struct ::N::A<int>::X { |
| 46 | int foo; |
| 47 | }; |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 48 | |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 49 | template<typename T> |
| 50 | struct TestA { |
Douglas Gregor | 7bb87fc | 2009-11-11 16:39:34 +0000 | [diff] [blame] | 51 | 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] | 52 | // expected-error{{expected member name}} |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 53 | }; |
John McCall | 63b4385 | 2010-04-29 23:50:39 +0000 | [diff] [blame] | 54 | |
| 55 | // Reduced from a Boost failure. |
| 56 | namespace test1 { |
| 57 | template <class T> struct pair { |
| 58 | T x; |
| 59 | T y; |
| 60 | |
| 61 | static T pair<T>::* const mem_array[2]; |
| 62 | }; |
| 63 | |
| 64 | template <class T> |
| 65 | T pair<T>::* const pair<T>::mem_array[2] = { &pair<T>::x, &pair<T>::y }; |
| 66 | } |
Douglas Gregor | 00b4b03 | 2010-05-14 04:53:42 +0000 | [diff] [blame] | 67 | |
| 68 | typedef int T; |
| 69 | namespace N1 { |
| 70 | template<typename T> T f0(); |
| 71 | } |
| 72 | |
| 73 | template<typename T> T N1::f0() { } |