diff options
Diffstat (limited to 'clang/test/SemaTemplate')
-rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp | 40 | ||||
-rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp | 40 |
2 files changed, 39 insertions, 41 deletions
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp index ae06055..b54b5a8 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp @@ -2,7 +2,7 @@ template<typename T, T val> struct A {}; -template<typename T, typename U> constexpr bool is_same = false; +template<typename T, typename U> constexpr bool is_same = false; // expected-note +{{here}} template<typename T> constexpr bool is_same<T, T> = true; namespace String { @@ -84,32 +84,34 @@ namespace PtrMem { constexpr int B::*b = &B::b; constexpr int C::*cb = b; constexpr int D::*db = b; - constexpr int E::*ecb = cb; - constexpr int E::*edb = db; + constexpr int E::*ecb = cb; // expected-note +{{here}} + constexpr int E::*edb = db; // expected-note +{{here}} constexpr int E::*e = &E::e; constexpr int D::*de = (int D::*)e; constexpr int C::*ce = (int C::*)e; - constexpr int B::*bde = (int B::*)de; - constexpr int B::*bce = (int B::*)ce; + constexpr int B::*bde = (int B::*)de; // expected-note +{{here}} + constexpr int B::*bce = (int B::*)ce; // expected-note +{{here}} + // FIXME: This should all be accepted, but we don't yet have a representation + // nor mangling for this form of template argument. using Ab = A<int B::*, b>; using Ab = A<int B::*, &B::b>; - using Abce = A<int B::*, bce>; - using Abde = A<int B::*, bde>; - static_assert(!is_same<Ab, Abce>, ""); - static_assert(!is_same<Ab, Abde>, ""); - static_assert(!is_same<Abce, Abde>, ""); - static_assert(is_same<Abce, A<int B::*, (int B::*)(int C::*)&E::e>>, ""); + using Abce = A<int B::*, bce>; // expected-error {{not supported}} + using Abde = A<int B::*, bde>; // expected-error {{not supported}} + static_assert(!is_same<Ab, Abce>, ""); // expected-error {{undeclared}} expected-error {{must be a type}} + static_assert(!is_same<Ab, Abde>, ""); // expected-error {{undeclared}} expected-error {{must be a type}} + static_assert(!is_same<Abce, Abde>, ""); // expected-error 2{{undeclared}} expected-error {{must be a type}} + static_assert(is_same<Abce, A<int B::*, (int B::*)(int C::*)&E::e>>, ""); // expected-error {{undeclared}} expected-error {{not supported}} using Ae = A<int E::*, e>; using Ae = A<int E::*, &E::e>; - using Aecb = A<int E::*, ecb>; - using Aedb = A<int E::*, edb>; - static_assert(!is_same<Ae, Aecb>, ""); - static_assert(!is_same<Ae, Aedb>, ""); - static_assert(!is_same<Aecb, Aedb>, ""); - static_assert(is_same<Aecb, A<int E::*, (int E::*)(int C::*)&B::b>>, ""); + using Aecb = A<int E::*, ecb>; // expected-error {{not supported}} + using Aedb = A<int E::*, edb>; // expected-error {{not supported}} + static_assert(!is_same<Ae, Aecb>, ""); // expected-error {{undeclared}} expected-error {{must be a type}} + static_assert(!is_same<Ae, Aedb>, ""); // expected-error {{undeclared}} expected-error {{must be a type}} + static_assert(!is_same<Aecb, Aedb>, ""); // expected-error 2{{undeclared}} expected-error {{must be a type}} + static_assert(is_same<Aecb, A<int E::*, (int E::*)(int C::*)&B::b>>, ""); // expected-error {{undeclared}} expected-error {{not supported}} using An = A<int E::*, nullptr>; using A0 = A<int E::*, (int E::*)0>; @@ -203,9 +205,9 @@ namespace Auto { struct Y : X {}; void type_affects_identity(B<&X::n>) {} - void type_affects_identity(B<(int Y::*)&X::n>) {} + void type_affects_identity(B<(int Y::*)&X::n>) {} // FIXME: expected-error {{non-type template argument of pointer-to-member type}} void type_affects_identity(B<(const int X::*)&X::n>) {} - void type_affects_identity(B<(const int Y::*)&X::n>) {} + void type_affects_identity(B<(const int Y::*)&X::n>) {} // FIXME: expected-error {{non-type template argument of pointer-to-member type}} // A case where we need to do auto-deduction, and check whether the // resulting dependent types match during partial ordering. These diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp index b5b8cad..e345a1f 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp @@ -8,8 +8,8 @@ namespace std { // floating-point arguments template<float> struct Float {}; -using F1 = Float<1.0f>; -using F1 = Float<2.0f / 2>; +using F1 = Float<1.0f>; // FIXME expected-error {{non-type template argument of type}} +using F1 = Float<2.0f / 2>; // FIXME expected-error {{non-type template argument of type}} struct S { int n[3]; } s; // expected-note 1+{{here}} union U { int a, b; } u; @@ -17,28 +17,24 @@ int n; // expected-note 1+{{here}} // pointers to subobjects template<int *> struct IntPtr {}; -using IPn = IntPtr<&n + 1>; -using IPn = IntPtr<&n + 1>; +using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}} +using IPn = IntPtr<&n + 1>; // FIXME expected-error {{refers to subobject}} -using IPn2 = IntPtr<&n + 2>; // expected-error {{not a constant expression}} expected-note {{cannot refer to element 2 of non-array object}} +using IP2 = IntPtr<&s.n[2]>; // FIXME expected-error {{refers to subobject}} +using IP2 = IntPtr<s.n + 2>; // FIXME expected-error {{refers to subobject}} -using IP2 = IntPtr<&s.n[2]>; -using IP2 = IntPtr<s.n + 2>; - -using IP3 = IntPtr<&s.n[3]>; -using IP3 = IntPtr<s.n + 3>; - -using IP5 = IntPtr<&s.n[5]>; // expected-error {{not a constant expression}} expected-note {{cannot refer to element 5 of array of 3 elements}} +using IP3 = IntPtr<&s.n[3]>; // FIXME expected-error {{refers to subobject}} +using IP3 = IntPtr<s.n + 3>; // FIXME expected-error {{refers to subobject}} template<int &> struct IntRef {}; -using IRn = IntRef<*(&n + 1)>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of 'n'}} -using IRn = IntRef<*(&n + 1)>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of 'n'}} +using IPn = IntRef<*(&n + 1)>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of 'n'}} +using IPn = IntRef<*(&n + 1)>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of 'n'}} -using IR2 = IntRef<s.n[2]>; -using IR2 = IntRef<*(s.n + 2)>; +using IP2 = IntRef<s.n[2]>; // FIXME expected-error {{refers to subobject}} +using IP2 = IntRef<*(s.n + 2)>; // FIXME expected-error {{refers to subobject}} -using IR3 = IntRef<s.n[3]>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of subobject of 's'}} -using IR3 = IntRef<*(s.n + 3)>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of subobject of 's'}} +using IP3 = IntRef<s.n[3]>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of subobject of 's'}} +using IP3 = IntRef<*(s.n + 3)>; // expected-error {{not a constant expression}} expected-note {{dereferenced pointer past the end of subobject of 's'}} // classes template<S> struct Struct {}; @@ -52,12 +48,12 @@ using U1 = Union<U{.b = 1}>; // expected-error {{different types}} // miscellaneous scalar types template<_Complex int> struct ComplexInt {}; -using CI = ComplexInt<1 + 3i>; -using CI = ComplexInt<3i + 1>; +using CI = ComplexInt<1 + 3i>; // FIXME: expected-error {{non-type template argument of type}} +using CI = ComplexInt<1 + 3i>; // FIXME: expected-error {{non-type template argument of type}} template<_Complex float> struct ComplexFloat {}; -using CF = ComplexFloat<1.0f + 3.0fi>; -using CF = ComplexFloat<3.0fi + 1.0f>; +using CF = ComplexFloat<1.0f + 3.0fi>; // FIXME: expected-error {{non-type template argument of type}} +using CF = ComplexFloat<1.0f + 3.0fi>; // FIXME: expected-error {{non-type template argument of type}} namespace ClassNTTP { struct A { // expected-note 2{{candidate}} |