Francois Pichet | fdde470 | 2011-09-22 22:14:56 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s |
Chandler Carruth | 62395c9 | 2011-04-25 06:34:35 +0000 | [diff] [blame] | 2 | |
| 3 | template <class T> |
| 4 | class A { |
| 5 | void foo() { |
| 6 | undeclared(); |
| 7 | } |
Francois Pichet | fdde470 | 2011-09-22 22:14:56 +0000 | [diff] [blame^] | 8 | void foo2(); |
Chandler Carruth | 62395c9 | 2011-04-25 06:34:35 +0000 | [diff] [blame] | 9 | }; |
| 10 | |
| 11 | template <class T> |
| 12 | class B { |
| 13 | void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}} |
| 14 | void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}} |
| 15 | }; |
| 16 | |
| 17 | |
| 18 | template <class T> |
| 19 | void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}} |
| 20 | } |
| 21 | |
| 22 | template <class T> |
| 23 | void A<T>::foo2() { |
| 24 | undeclared(); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | template <class T> |
| 29 | void foo3() { |
| 30 | undeclared(); |
| 31 | } |
| 32 | |
| 33 | template void A<int>::foo2(); |
| 34 | |
| 35 | |
| 36 | void undeclared() |
| 37 | { |
| 38 | |
| 39 | } |
| 40 | |
| 41 | template <class T> void foo5() {} //expected-note {{previous definition is here}} |
| 42 | template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}} |
Francois Pichet | fdde470 | 2011-09-22 22:14:56 +0000 | [diff] [blame^] | 43 | |
| 44 | |
| 45 | |
| 46 | namespace Inner_Outer_same_template_param_name { |
| 47 | |
| 48 | template <class T> |
| 49 | class Outmost { |
| 50 | public: |
| 51 | template <class T> |
| 52 | class Inner { |
| 53 | public: |
| 54 | void f() { |
| 55 | T* var; |
| 56 | } |
| 57 | }; |
| 58 | }; |
| 59 | |
| 60 | } |
| 61 | |