Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | namespace N { |
| 4 | namespace M { |
| 5 | template<typename T> struct Promote; // expected-note{{previous definition is here}} |
| 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; } |
| 24 | M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } |
| 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 | |
| 31 | N::M::template; // expected-error{{expected template name after 'template' keyword in nested name specifier}} \ |
| 32 | // expected-error{{expected unqualified-id}} |
| 33 | |
| 34 | N::M::template Promote; // expected-error{{expected '<' after 'template Promote' in nested name specifier}} \ |
| 35 | // expected-error{{C++ requires a type specifier for all declarations}} \ |
Douglas Gregor | 656de63 | 2009-03-11 23:52:16 +0000 | [diff] [blame^] | 36 | // expected-error{{redefinition of 'Promote' as different kind of symbol}} |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 37 | |
| 38 | namespace N { |
| 39 | template<typename T> struct A; |
| 40 | |
| 41 | template<> |
| 42 | struct A<int> { |
| 43 | struct X; |
| 44 | }; |
| 45 | } |
| 46 | |
| 47 | struct ::N::A<int>::X { |
| 48 | int foo; |
| 49 | }; |