2009-12-28 06:31:18 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2015-12-10 09:07:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
2013-12-04 11:51:14 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -fdelayed-template-parsing
|
2015-12-10 09:07:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -fdelayed-template-parsing
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -fdelayed-template-parsing
|
2009-12-28 06:31:18 +08:00
|
|
|
|
|
|
|
template<typename T> struct A {};
|
|
|
|
|
|
|
|
// Check for template argument lists followed by junk
|
|
|
|
// FIXME: The diagnostics here aren't great...
|
2020-03-28 09:50:02 +08:00
|
|
|
A<int+> int x; // expected-error {{expected '>'}} expected-note {{to match this '<'}} expected-error {{expected unqualified-id}}
|
|
|
|
A<int x; // expected-error {{expected '>'}} expected-note {{to match this '<'}}
|
2009-12-28 06:31:18 +08:00
|
|
|
|
2011-01-11 08:33:19 +08:00
|
|
|
// PR8912
|
|
|
|
template <bool> struct S {};
|
|
|
|
S<bool(2 > 1)> s;
|
2012-06-18 14:11:04 +08:00
|
|
|
|
|
|
|
// Test behavior when a template-id is ended by a token which starts with '>'.
|
|
|
|
namespace greatergreater {
|
|
|
|
template<typename T> struct S { S(); S(T); };
|
|
|
|
void f(S<int>=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}}
|
|
|
|
void f(S<S<int>>=S<int>()); // expected-error {{use '> >'}} expected-error {{use '> ='}}
|
|
|
|
template<typename T> void t();
|
2021-06-22 09:48:51 +08:00
|
|
|
struct R {
|
|
|
|
friend void operator==(void (*)(), R) {}
|
|
|
|
friend void operator>=(void (*)(), R) {}
|
|
|
|
};
|
2012-06-18 14:11:04 +08:00
|
|
|
void g() {
|
2021-06-22 09:48:51 +08:00
|
|
|
(void)(&t<int>==R()); // expected-error {{use '> ='}}
|
|
|
|
(void)(&t<int>>=R()); // expected-error {{use '> >'}}
|
|
|
|
(void)(&t<S<int>>>=R());
|
2015-12-10 09:07:17 +08:00
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-error@-2 {{use '> >'}}
|
|
|
|
#endif
|
2021-06-22 09:48:51 +08:00
|
|
|
(void)(&t<S<int>>==R()); // expected-error {{use '> >'}} expected-error {{use '> ='}}
|
2012-06-18 14:11:04 +08:00
|
|
|
}
|
|
|
|
}
|
2012-08-18 08:55:03 +08:00
|
|
|
|
|
|
|
namespace PR5925 {
|
|
|
|
template <typename x>
|
|
|
|
class foo { // expected-note {{here}}
|
|
|
|
};
|
|
|
|
void bar(foo *X) { // expected-error {{requires template arguments}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace PR13210 {
|
|
|
|
template <class T>
|
|
|
|
class C {}; // expected-note {{here}}
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
new C(); // expected-error {{requires template arguments}}
|
|
|
|
}
|
|
|
|
}
|
2013-08-10 13:54:47 +08:00
|
|
|
|
|
|
|
// Don't emit spurious messages
|
|
|
|
namespace pr16225add {
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct Known { }; // expected-note 3 {{template is declared here}}
|
|
|
|
template<class T1, typename T2> struct X;
|
|
|
|
template<class T1, typename T2> struct ABC; // expected-note {{template is declared here}}
|
|
|
|
template<int N1, int N2> struct ABC2 {};
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,T2> // expected-error {{no template named 'UnknownBase'}}
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo2 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,T2>, // expected-error {{no template named 'UnknownBase'}}
|
2013-08-10 13:54:47 +08:00
|
|
|
Known<T1> // expected-error {{too few template arguments for class template 'Known'}}
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo3 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,T2,ABC<T2,T1> > // expected-error {{no template named 'UnknownBase'}}
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo4 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,ABC<T2> >, // expected-error {{too few template arguments for class template 'ABC'}}
|
2013-08-10 13:54:47 +08:00
|
|
|
Known<T1> // expected-error {{too few template arguments for class template 'Known'}}
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo5 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,T2,ABC<T2,T1>> // expected-error {{no template named 'UnknownBase'}}
|
2015-12-10 09:07:17 +08:00
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-error@-2 {{use '> >'}}
|
|
|
|
#endif
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo6 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,ABC<T2,T1>>, // expected-error {{no template named 'UnknownBase'}}
|
2015-12-10 09:07:17 +08:00
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-error@-2 {{use '> >'}}
|
|
|
|
#endif
|
2013-08-10 13:54:47 +08:00
|
|
|
Known<T1> // expected-error {{too few template arguments for class template 'Known'}}
|
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2, int N> struct foo7 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<T1,T2,(N>1)> // expected-error {{no template named 'UnknownBase'}}
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo8 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<X<int,int>,X<int,int>> // expected-error {{no template named 'UnknownBase'}}
|
2015-12-10 09:07:17 +08:00
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-error@-2 {{use '> >'}}
|
|
|
|
#endif
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo9 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<Known<int,int>,X<int,int>> // expected-error {{no template named 'UnknownBase'}}
|
2015-12-10 09:07:17 +08:00
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-error@-2 {{use '> >'}}
|
|
|
|
#endif
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<class T1, typename T2> struct foo10 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<Known<int,int>,X<int,X<int,int>>> // expected-error {{no template named 'UnknownBase'}}
|
2015-12-10 09:07:17 +08:00
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-error@-2 {{use '> >'}}
|
|
|
|
#endif
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
template<int N1, int N2> struct foo11 :
|
2019-05-09 11:31:27 +08:00
|
|
|
UnknownBase<2<N1,N2<4> // expected-error {{no template named 'UnknownBase'}}
|
2013-08-10 13:54:47 +08:00
|
|
|
{ };
|
|
|
|
|
|
|
|
}
|
2014-09-24 05:05:52 +08:00
|
|
|
|
|
|
|
namespace PR18793 {
|
|
|
|
template<typename T, T> struct S {};
|
|
|
|
template<typename T> int g(S<T, (T())> *);
|
|
|
|
}
|
2019-05-16 07:36:14 +08:00
|
|
|
|
|
|
|
namespace r360308_regression {
|
|
|
|
template<typename> struct S1 { static int const n = 0; };
|
|
|
|
template<int, typename> struct S2 { typedef int t; };
|
|
|
|
template<typename T> struct S3 { typename S2<S1<T>::n < 0, int>::t n; };
|
|
|
|
|
|
|
|
template<typename FT> bool f(FT p) {
|
|
|
|
const bool a = p.first<FT(0), b = p.second>FT(0);
|
|
|
|
return a == b;
|
|
|
|
}
|
|
|
|
}
|