Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Douglas Gregor | 9dc8bd3 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 4 | |
| 5 | // PR4607 |
| 6 | template <class T> struct X {}; |
| 7 | |
| 8 | template <> struct X<char> |
| 9 | { |
| 10 | static char* g(); |
| 11 | }; |
| 12 | |
| 13 | template <class T> struct X2 {}; |
| 14 | |
| 15 | template <class U> |
| 16 | struct X2<U*> { |
| 17 | static void f() { |
| 18 | X<U>::g(); |
| 19 | } |
| 20 | }; |
| 21 | |
| 22 | void a(char *a, char *b) {X2<char*>::f();} |
Douglas Gregor | e902956 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 23 | |
| 24 | namespace WonkyAccess { |
| 25 | template<typename T> |
| 26 | struct X { |
| 27 | int m; |
| 28 | }; |
| 29 | |
| 30 | template<typename U> |
| 31 | class Y; |
| 32 | |
| 33 | template<typename U> |
| 34 | struct Y<U*> : X<U> { }; |
| 35 | |
| 36 | template<> |
| 37 | struct Y<float*> : X<float> { }; |
| 38 | |
| 39 | int f(Y<int*> y, Y<float*> y2) { |
| 40 | return y.m + y2.m; |
| 41 | } |
| 42 | } |
Douglas Gregor | b4f4d51 | 2011-05-04 21:55:00 +0000 | [diff] [blame] | 43 | |
| 44 | // <rdar://problem/9169404> |
| 45 | namespace rdar9169404 { |
| 46 | template<typename T, T N> struct X { }; |
| 47 | template<bool C> struct X<bool, C> { |
| 48 | typedef int type; |
| 49 | }; |
| 50 | |
| 51 | X<bool, -1>::type value; |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 52 | #if __cplusplus >= 201103L |
| 53 | // expected-error@-2 {{non-type template argument evaluates to -1, which cannot be narrowed to type 'bool'}} |
| 54 | #else |
| 55 | // expected-no-diagnostics |
| 56 | #endif |
Douglas Gregor | b4f4d51 | 2011-05-04 21:55:00 +0000 | [diff] [blame] | 57 | } |