Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s |
Larisse Voufo | f73da98 | 2014-07-30 00:49:55 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -std=c++1y -verify %s -DCXX1Y |
| 3 | |
| 4 | #ifndef CXX1Y |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 5 | |
| 6 | template<typename T, typename U, U> using alias_ref = T; |
| 7 | template<typename T, typename U, U> void func_ref() {} |
| 8 | template<typename T, typename U, U> struct class_ref {}; |
| 9 | |
| 10 | template<int N> |
| 11 | struct U { |
| 12 | static int a; |
| 13 | }; |
| 14 | |
Larisse Voufo | b6fab26 | 2014-07-29 18:44:19 +0000 | [diff] [blame] | 15 | template<int N> struct S; // expected-note 6{{here}} |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 16 | |
| 17 | template<int N> |
Larisse Voufo | b6fab26 | 2014-07-29 18:44:19 +0000 | [diff] [blame] | 18 | int U<N>::a = S<N>::kError; // expected-error 6{{undefined}} |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 19 | |
| 20 | template<typename T> |
| 21 | void f() { |
Larisse Voufo | b6fab26 | 2014-07-29 18:44:19 +0000 | [diff] [blame] | 22 | (void)alias_ref<int, int&, U<0>::a>(); // expected-note {{here}} |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 23 | (void)func_ref<int, int&, U<1>::a>(); // expected-note {{here}} |
| 24 | (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}} |
| 25 | }; |
| 26 | |
Larisse Voufo | f73da98 | 2014-07-30 00:49:55 +0000 | [diff] [blame] | 27 | |
Larisse Voufo | b6fab26 | 2014-07-29 18:44:19 +0000 | [diff] [blame] | 28 | template<int N> |
| 29 | void fi() { |
| 30 | (void)alias_ref<int, int&, U<N>::a>(); // expected-note {{here}} |
| 31 | (void)func_ref<int, int&, U<N+1>::a>(); // expected-note {{here}} |
| 32 | (void)class_ref<int, int&, U<N+2>::a>(); // expected-note {{here}} |
| 33 | }; |
| 34 | |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 35 | int main() { |
Larisse Voufo | b6fab26 | 2014-07-29 18:44:19 +0000 | [diff] [blame] | 36 | f<int>(); // NOTE: Non-dependent name uses are type-checked at template definition time. |
| 37 | fi<10>(); // expected-note 3{{here}} |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | namespace N { |
| 41 | template<typename T> struct S { static int n; }; |
| 42 | template<typename T> int S<T>::n = 5; |
| 43 | void g(int*); |
| 44 | template<typename T> int f() { |
| 45 | int k[S<T>::n]; |
| 46 | g(k); |
| 47 | return k[3]; |
| 48 | } |
| 49 | int j = f<int>(); |
| 50 | } |
Larisse Voufo | b6fab26 | 2014-07-29 18:44:19 +0000 | [diff] [blame] | 51 | |
Larisse Voufo | f73da98 | 2014-07-30 00:49:55 +0000 | [diff] [blame] | 52 | #else |
| 53 | // expected-no-diagnostics |
| 54 | |
| 55 | namespace { template<typename> extern int n; } |
| 56 | template<typename T> int g() { return n<int>; } |
Serge Pavlov | 7dcc97e | 2016-04-19 06:19:52 +0000 | [diff] [blame] | 57 | namespace { extern template int n<int>; } |
Larisse Voufo | f73da98 | 2014-07-30 00:49:55 +0000 | [diff] [blame] | 58 | |
| 59 | #endif |
| 60 | |