diff options
Diffstat (limited to 'test/SemaTemplate/default-arguments.cpp')
-rw-r--r-- | test/SemaTemplate/default-arguments.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index 439a303..740a5a9 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s template<typename T, int N = 2> struct X; // expected-note{{template is declared here}} X<int, 1> *x1; @@ -142,7 +144,10 @@ namespace PR9643 { namespace PR16288 { template<typename X> struct S { - template<typename T = int, typename U> // expected-warning {{C++11}} + template<typename T = int, typename U> +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} +#endif void f(); }; template<typename X> @@ -152,10 +157,25 @@ namespace PR16288 { namespace DR1635 { template <class T> struct X { - template <class U = typename T::type> static void f(int) {} // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} \ - // expected-warning {{C++11}} + template <class U = typename T::type> static void f(int) {} // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} +#endif static void f(...) {} }; int g() { X<int>::f(0); } // expected-note {{in instantiation of template class 'DR1635::X<int>' requested here}} } + +namespace NondefDecls { + template<typename T> void f1() { + int g1(int defarg = T::error); // expected-error{{type 'int' cannot be used prior to '::' because it has no members}} + } + template void f1<int>(); // expected-note{{in instantiation of function template specialization 'NondefDecls::f1<int>' requested here}} +} + +template <typename T> +struct C { + C(T t = ); // expected-error {{expected expression}} +}; +C<int> obj; |