xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/crash-lambda-12645424.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // rdar://12645424, crash due to a double-free
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc template<typename _Tp> struct __add_lvalue_reference_helper {};
6*f4a2713aSLionel Sambuc template<typename _Tp> struct add_lvalue_reference :  __add_lvalue_reference_helper<_Tp> {
7*f4a2713aSLionel Sambuc   typedef _Tp type;
8*f4a2713aSLionel Sambuc };
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc template<typename... Types> struct type_list;
11*f4a2713aSLionel Sambuc template<typename , template<typename> class... Funs> struct C;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc template<typename T> struct C<T> {
14*f4a2713aSLionel Sambuc 	typedef T type;
15*f4a2713aSLionel Sambuc };
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc template<typename T, template<typename>  class Fun0, template<typename> class... Funs> struct C<T, Fun0, Funs...> {
18*f4a2713aSLionel Sambuc   typedef  typename C<typename Fun0<T>::type, Funs...>::type type;
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc template<class , template<typename> class... Funs> struct tl_map;
22*f4a2713aSLionel Sambuc template<typename... Ts, template<typename> class... Funs> struct tl_map<type_list<Ts...>, Funs...> {
23*f4a2713aSLionel Sambuc   typedef type_list<typename C<Ts, Funs...>::type...> type;
24*f4a2713aSLionel Sambuc };
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc template<   class Pattern> struct F {
27*f4a2713aSLionel Sambuc  typedef Pattern  filtered_pattern;
28*f4a2713aSLionel Sambuc   tl_map< filtered_pattern, add_lvalue_reference > type;
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc template<class, class Pattern> struct get_case {
32*f4a2713aSLionel Sambuc   F<Pattern> type;
33*f4a2713aSLionel Sambuc };
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc template<class Pattern> struct rvalue_builder {
36*f4a2713aSLionel Sambuc   template<typename Expr> typename get_case<Expr, Pattern>::type operator>>(Expr ); // expected-note {{candidate template ignored}}
37*f4a2713aSLionel Sambuc };
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc template<typename Arg0> rvalue_builder< type_list<Arg0> > on(const Arg0& ) ;
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc class Z {
__anon5d9c37e60102null42*f4a2713aSLionel Sambuc   int empty = on(0) >> [] {}; // expected-error {{invalid operands to binary expression}}
43*f4a2713aSLionel Sambuc };
44