diff options
Diffstat (limited to 'test/SemaCXX/PR10177.cpp')
| -rw-r--r-- | test/SemaCXX/PR10177.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/test/SemaCXX/PR10177.cpp b/test/SemaCXX/PR10177.cpp index 8d745de0a6a1..e361ff37bc03 100644 --- a/test/SemaCXX/PR10177.cpp +++ b/test/SemaCXX/PR10177.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++1y -verify %s -DCXX1Y + +#ifndef CXX1Y template<typename T, typename U, U> using alias_ref = T; template<typename T, typename U, U> void func_ref() {} @@ -9,22 +12,29 @@ struct U { static int a; }; -template<int N> struct S; // expected-note 2{{here}} +template<int N> struct S; // expected-note 6{{here}} template<int N> -int U<N>::a = S<N>::kError; // expected-error 2{{undefined}} +int U<N>::a = S<N>::kError; // expected-error 6{{undefined}} template<typename T> void f() { - // FIXME: The standard suggests that U<0>::a is odr-used by this expression, - // but it's not entirely clear that's the right behaviour. - (void)alias_ref<int, int&, U<0>::a>(); + (void)alias_ref<int, int&, U<0>::a>(); // expected-note {{here}} (void)func_ref<int, int&, U<1>::a>(); // expected-note {{here}} (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}} }; + +template<int N> +void fi() { + (void)alias_ref<int, int&, U<N>::a>(); // expected-note {{here}} + (void)func_ref<int, int&, U<N+1>::a>(); // expected-note {{here}} + (void)class_ref<int, int&, U<N+2>::a>(); // expected-note {{here}} +}; + int main() { - f<int>(); // expected-note 2{{here}} + f<int>(); // NOTE: Non-dependent name uses are type-checked at template definition time. + fi<10>(); // expected-note 3{{here}} } namespace N { @@ -38,3 +48,12 @@ namespace N { } int j = f<int>(); } + +#else +// expected-no-diagnostics + +namespace { template<typename> extern int n; } +template<typename T> int g() { return n<int>; } + +#endif + |
