diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaTemplate/default-arguments.cpp | 24 | ||||
-rw-r--r-- | test/SemaTemplate/nested-name-spec-template.cpp | 17 |
2 files changed, 24 insertions, 17 deletions
diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index fc3f9fe9b9..8352afdb0d 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.cpp @@ -1,5 +1,4 @@ // RUN: clang-cc -fsyntax-only -verify %s - template<typename T, int N = 2> struct X; // expected-note{{template is declared here}} X<int, 1> *x1; @@ -80,16 +79,31 @@ X2<int>::NonType1<> x2_nontype1_bad; // expected-note{{instantiation of default X2<int>::Inner3<float>::VeryInner<> vi; X2<char>::Inner3<int>::NonType2<> x2_deep_nontype; - template<typename T, typename U> struct is_same { static const bool value = false; }; template<typename T> struct is_same<T, T> { static const bool value = true; }; -static int array1[is_same<__typeof__(vi), +int array1[is_same<__typeof__(vi), X2<int>::Inner3<float>::VeryInner<int, float> >::value? 1 : -1]; -static int array2[is_same<__typeof(x2_deep_nontype), - X2<char>::Inner3<int>::NonType2<sizeof(char), sizeof(int), +int array2[is_same<__typeof(x2_deep_nontype), + X2<char>::Inner3<int>::NonType2<sizeof(char), sizeof(int), sizeof(char)+sizeof(int)> >::value? 1 : -1]; + +// Template template parameter defaults +template<template<typename T> class X = X2> struct X3 { }; +int array3[is_same<X3<>, X3<X2> >::value? 1 : -1]; + +struct add_pointer { + template<typename T> + struct apply { + typedef T* type; + }; +}; + +template<typename T, template<typename> class X = T::template apply> + struct X4; +int array4[is_same<X4<add_pointer>, + X4<add_pointer, add_pointer::apply> >::value? 1 : -1]; diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp index 1bdc7a89d4..e936640f5e 100644 --- a/test/SemaTemplate/nested-name-spec-template.cpp +++ b/test/SemaTemplate/nested-name-spec-template.cpp @@ -28,11 +28,8 @@ N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; } ::N::M::Promote<int>::type *ret_intptr6(int* ip) { return ip; } -N::M::template; // expected-error{{expected template name after 'template' keyword in nested name specifier}} \ - // expected-error{{expected unqualified-id}} - -N::M::template Promote; // expected-error{{expected '<' after 'template Promote' in nested name specifier}} \ -// expected-error{{C++ requires a type specifier for all declarations}} +N::M::template; // expected-error{{expected unqualified-id}} +N::M::template Promote; // expected-error{{expected unqualified-id}} namespace N { template<typename T> struct A; @@ -49,13 +46,9 @@ struct ::N::A<int>::X { int foo; }; -#if 0 -// FIXME: the following crashes the parser, because Sema has no way to -// communicate that the "dependent" template-name N::template B doesn't -// actually refer to a template. template<typename T> struct TestA { - typedef typename N::template B<T>::type type; // xpected-error{{'B' following the 'template' keyword does not refer to a template}} - // FIXME: should show what B *does* refer to. + typedef typename N::template B<T>::type type; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \ + // expected-error{{identifier or template-id}} \ + // expected-error{{expected member name}} }; -#endif |