Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s |
Richard Smith | 07cea19 | 2013-04-29 08:53:40 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 3 | |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 4 | class A { |
| 5 | public: |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 6 | template<class U> A(U p) {} |
| 7 | template<> A(int p) { |
| 8 | // expected-warning@-1 {{explicit specialization of 'A' within class scope is a Microsoft extension}} |
| 9 | } |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 10 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 11 | template<class U> void f(U p) {} |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 12 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 13 | template<> void f(int p) { |
| 14 | // expected-warning@-1 {{explicit specialization of 'f' within class scope is a Microsoft extension}} |
| 15 | } |
| 16 | |
| 17 | void f(int p) {} |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 18 | }; |
| 19 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 20 | void test1() { |
| 21 | A a(3); |
| 22 | char *b; |
| 23 | a.f(b); |
| 24 | a.f<int>(99); |
| 25 | a.f(100); |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 28 | template<class T> class B { |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 29 | public: |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 30 | template<class U> B(U p) {} |
| 31 | template<> B(int p) { |
| 32 | // expected-warning@-1 {{explicit specialization of 'B<T>' within class scope is a Microsoft extension}} |
| 33 | } |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 34 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 35 | template<class U> void f(U p) { T y = 9; } |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 36 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 37 | template<> void f(int p) { |
| 38 | // expected-warning@-1 {{explicit specialization of 'f' within class scope is a Microsoft extension}} |
| 39 | T a = 3; |
| 40 | } |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 41 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 42 | void f(int p) { T a = 3; } |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 45 | void test2() { |
| 46 | B<char> b(3); |
| 47 | char *ptr; |
| 48 | b.f(ptr); |
| 49 | b.f<int>(99); |
| 50 | b.f(100); |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Nico Weber | 7b5a716 | 2012-06-25 17:21:05 +0000 | [diff] [blame] | 53 | namespace PR12709 { |
| 54 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 55 | template<class T> class TemplateClass { |
| 56 | void member_function() { specialized_member_template<false>(); } |
| 57 | |
| 58 | template<bool b> void specialized_member_template() {} |
| 59 | |
| 60 | template<> void specialized_member_template<false>() { |
| 61 | // expected-warning@-1 {{explicit specialization of 'specialized_member_template' within class scope is a Microsoft extension}} |
Nico Weber | 7b5a716 | 2012-06-25 17:21:05 +0000 | [diff] [blame] | 62 | } |
Nico Weber | 7b5a716 | 2012-06-25 17:21:05 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Richard Smith | 3c9198f | 2013-12-13 22:26:20 +0000 | [diff] [blame^] | 65 | void f() { TemplateClass<int> t; } |
Nico Weber | 7b5a716 | 2012-06-25 17:21:05 +0000 | [diff] [blame] | 66 | } |