Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -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; } |
| 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}} \ |
Chris Lattner | f4382f5 | 2009-04-14 22:17:06 +0000 | [diff] [blame^] | 35 | // expected-error{{C++ requires a type specifier for all declarations}} |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 36 | |
| 37 | namespace N { |
| 38 | template<typename T> struct A; |
| 39 | |
| 40 | template<> |
| 41 | struct A<int> { |
| 42 | struct X; |
| 43 | }; |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 44 | |
| 45 | struct B; |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | struct ::N::A<int>::X { |
| 49 | int foo; |
| 50 | }; |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 51 | |
| 52 | #if 0 |
| 53 | // FIXME: the following crashes the parser, because Sema has no way to |
Douglas Gregor | 31a19b6 | 2009-04-01 21:51:26 +0000 | [diff] [blame] | 54 | // communicate that the "dependent" template-name N::template B doesn't |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 55 | // actually refer to a template. |
| 56 | template<typename T> |
| 57 | struct TestA { |
| 58 | typedef typename N::template B<T>::type type; // xpected-error{{'B' following the 'template' keyword does not refer to a template}} |
| 59 | // FIXME: should show what B *does* refer to. |
| 60 | }; |
| 61 | #endif |