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}} |
Francois Pichet | 9d38dbc | 2011-11-18 23:47:17 +0000 | [diff] [blame^] | 15 | |
| 16 | friend void foo3() { |
| 17 | undeclared(); |
| 18 | } |
Chandler Carruth | 62395c9 | 2011-04-25 06:34:35 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | |
| 22 | template <class T> |
| 23 | void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}} |
| 24 | } |
| 25 | |
| 26 | template <class T> |
| 27 | void A<T>::foo2() { |
| 28 | undeclared(); |
| 29 | } |
| 30 | |
| 31 | |
| 32 | template <class T> |
| 33 | void foo3() { |
| 34 | undeclared(); |
| 35 | } |
| 36 | |
| 37 | template void A<int>::foo2(); |
| 38 | |
| 39 | |
| 40 | void undeclared() |
| 41 | { |
| 42 | |
| 43 | } |
| 44 | |
| 45 | template <class T> void foo5() {} //expected-note {{previous definition is here}} |
| 46 | template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}} |
Francois Pichet | fdde470 | 2011-09-22 22:14:56 +0000 | [diff] [blame] | 47 | |
| 48 | |
| 49 | |
| 50 | namespace Inner_Outer_same_template_param_name { |
| 51 | |
| 52 | template <class T> |
| 53 | class Outmost { |
| 54 | public: |
| 55 | template <class T> |
| 56 | class Inner { |
| 57 | public: |
| 58 | void f() { |
| 59 | T* var; |
| 60 | } |
| 61 | }; |
| 62 | }; |
| 63 | |
| 64 | } |
| 65 | |