Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s |
Richard Smith | fed844d | 2013-04-29 08:53:40 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 3 | |
| 4 | |
| 5 | class A { |
| 6 | public: |
| 7 | template <class U> |
| 8 | A(U p) { |
| 9 | } |
| 10 | template <> |
Francois Pichet | 2fd9a47 | 2011-08-14 22:30:29 +0000 | [diff] [blame] | 11 | A(int p) { // expected-warning{{explicit specialization of 'A' within class scope is a Microsoft extension}} |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | template <class U> |
| 15 | void f(U p) { |
| 16 | } |
| 17 | |
| 18 | template <> |
Francois Pichet | 2fd9a47 | 2011-08-14 22:30:29 +0000 | [diff] [blame] | 19 | void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}} |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | void f(int p) { |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | void test1() |
| 27 | { |
| 28 | A a(3); |
| 29 | char* b ; |
| 30 | a.f(b); |
| 31 | a.f<int>(99); |
| 32 | a.f(100); |
| 33 | } |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | template <class T> |
| 39 | class B { |
| 40 | public: |
| 41 | template <class U> |
| 42 | B(U p) { |
| 43 | } |
| 44 | template <> |
Francois Pichet | 2fd9a47 | 2011-08-14 22:30:29 +0000 | [diff] [blame] | 45 | B(int p) { // expected-warning{{explicit specialization of 'B<T>' within class scope is a Microsoft extension}} |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | template <class U> |
| 49 | void f(U p) { |
| 50 | T y = 9; |
| 51 | } |
| 52 | |
| 53 | |
| 54 | template <> |
Francois Pichet | 2fd9a47 | 2011-08-14 22:30:29 +0000 | [diff] [blame] | 55 | void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}} |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 56 | T a = 3; |
| 57 | } |
| 58 | |
| 59 | void f(int p) { |
| 60 | T a = 3; |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | void test2() |
| 65 | { |
| 66 | B<char> b(3); |
| 67 | char* ptr; |
| 68 | b.f(ptr); |
| 69 | b.f<int>(99); |
| 70 | b.f(100); |
| 71 | } |
| 72 | |
Nico Weber | 6b02009 | 2012-06-25 17:21:05 +0000 | [diff] [blame] | 73 | |
| 74 | namespace PR12709 { |
| 75 | |
| 76 | template<class T> |
| 77 | class TemplateClass { |
| 78 | void member_function() { |
| 79 | specialized_member_template<false>(); |
| 80 | } |
| 81 | |
| 82 | template<bool b> |
| 83 | void specialized_member_template() {} |
| 84 | |
| 85 | template<> |
| 86 | void specialized_member_template<false>() {} // expected-warning{{explicit specialization of 'specialized_member_template' within class scope is a Microsoft extension}} |
| 87 | }; |
| 88 | |
| 89 | void f() { |
| 90 | TemplateClass<int> t; |
| 91 | } |
| 92 | |
| 93 | } |