| 1 |
// PR ipa/63587 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-O2 -Wno-return-type" } |
| 4 |
|
| 5 |
namespace boost { |
| 6 |
class basic_cstring |
| 7 |
{ |
| 8 |
public: |
| 9 |
basic_cstring (char *); |
| 10 |
}; |
| 11 |
template <typename> struct identity |
| 12 |
{ |
| 13 |
}; |
| 14 |
struct make_identity; |
| 15 |
struct function_buffer |
| 16 |
{ |
| 17 |
}; |
| 18 |
template <typename FunctionObj> struct function_obj_invoker0 |
| 19 |
{ |
| 20 |
static int |
| 21 |
invoke (function_buffer &) |
| 22 |
{ |
| 23 |
FunctionObj f; |
| 24 |
f (); |
| 25 |
return 0; |
| 26 |
} |
| 27 |
}; |
| 28 |
template <typename FunctionObj> struct get_function_obj_invoker0 |
| 29 |
{ |
| 30 |
typedef function_obj_invoker0<FunctionObj> type; |
| 31 |
}; |
| 32 |
template <typename FunctionObj> struct apply |
| 33 |
{ |
| 34 |
typedef typename get_function_obj_invoker0<FunctionObj>::type invoker_type; |
| 35 |
}; |
| 36 |
struct basic_vtable0 |
| 37 |
{ |
| 38 |
typedef int (*invoker_type)(function_buffer &); |
| 39 |
template <typename F> void assign_to (F, function_buffer); |
| 40 |
invoker_type invoker; |
| 41 |
}; |
| 42 |
class function0 |
| 43 |
{ |
| 44 |
public: |
| 45 |
template <typename Functor> function0 (Functor) |
| 46 |
{ |
| 47 |
typedef typename apply<Functor>::invoker_type invoker_type; |
| 48 |
basic_vtable0 stored_vtable { invoker_type::invoke }; |
| 49 |
stored_vtable.assign_to (0, functor); |
| 50 |
} |
| 51 |
function_buffer functor; |
| 52 |
}; |
| 53 |
class function : function0 |
| 54 |
{ |
| 55 |
public: |
| 56 |
template <typename Functor> function (Functor f) : function0 (f) {} |
| 57 |
}; |
| 58 |
class test_unit_generator |
| 59 |
{ |
| 60 |
}; |
| 61 |
class test_case |
| 62 |
{ |
| 63 |
public: |
| 64 |
test_case (basic_cstring, basic_cstring, int, function); |
| 65 |
}; |
| 66 |
struct auto_test_unit_registrar |
| 67 |
{ |
| 68 |
auto_test_unit_registrar (test_unit_generator); |
| 69 |
}; |
| 70 |
template <typename F> F unwrap (F, int); |
| 71 |
struct for_each_impl |
| 72 |
{ |
| 73 |
template <typename Iterator, typename LastIterator, typename TransformFunc, |
| 74 |
typename F> |
| 75 |
static void |
| 76 |
execute (Iterator, LastIterator, TransformFunc, F f) |
| 77 |
{ |
| 78 |
identity<char> __trans_tmp_1; |
| 79 |
unwrap (f, 0)(__trans_tmp_1); |
| 80 |
} |
| 81 |
}; |
| 82 |
template <typename, typename, typename F> |
| 83 |
void |
| 84 |
for_each (F f) |
| 85 |
{ |
| 86 |
for_each_impl::execute (0, 0, 0, f); |
| 87 |
} |
| 88 |
template <typename TestCaseTemplate> class test_case_template_invoker |
| 89 |
{ |
| 90 |
public: |
| 91 |
void operator()() |
| 92 |
{ |
| 93 |
TestCaseTemplate::run (0); |
| 94 |
} |
| 95 |
}; |
| 96 |
template <typename Generator, typename TestCaseTemplate> |
| 97 |
struct generate_test_case_4_type |
| 98 |
{ |
| 99 |
generate_test_case_4_type (basic_cstring, basic_cstring, int, Generator G) |
| 100 |
: m_test_case_name (0), m_test_case_file (0), m_holder (G) |
| 101 |
{ |
| 102 |
} |
| 103 |
template <typename TestType> void operator()(identity<TestType>) |
| 104 |
{ |
| 105 |
test_case (0, 0, 0, test_case_template_invoker<TestCaseTemplate> ()); |
| 106 |
} |
| 107 |
basic_cstring m_test_case_name; |
| 108 |
basic_cstring m_test_case_file; |
| 109 |
Generator m_holder; |
| 110 |
}; |
| 111 |
template <typename TestCaseTemplate> |
| 112 |
class template_test_case_gen : public test_unit_generator |
| 113 |
{ |
| 114 |
public: |
| 115 |
template_test_case_gen (basic_cstring, basic_cstring, int) |
| 116 |
{ |
| 117 |
for_each<int, make_identity> ( |
| 118 |
generate_test_case_4_type<template_test_case_gen, TestCaseTemplate> ( |
| 119 |
0, 0, 0, *this)); |
| 120 |
} |
| 121 |
}; |
| 122 |
class attribute_name |
| 123 |
{ |
| 124 |
int m_id; |
| 125 |
|
| 126 |
public: |
| 127 |
attribute_name (char); |
| 128 |
}; |
| 129 |
template <typename> struct term; |
| 130 |
namespace exprns_ { |
| 131 |
template <typename> struct expr; |
| 132 |
} |
| 133 |
using exprns_::expr; |
| 134 |
template <typename T> struct Trans_NS_proto_terminal |
| 135 |
{ |
| 136 |
typedef expr<term<T> > type; |
| 137 |
}; |
| 138 |
namespace exprns_ { |
| 139 |
template <typename Arg0> struct expr<term<Arg0> > |
| 140 |
{ |
| 141 |
Arg0 child0; |
| 142 |
}; |
| 143 |
} |
| 144 |
template <typename Expr> struct actor |
| 145 |
{ |
| 146 |
typename Trans_NS_proto_terminal<Expr>::type proto_expr_; |
| 147 |
}; |
| 148 |
template <template <typename> class Actor = actor> struct terminal |
| 149 |
{ |
| 150 |
typedef Actor<int> type; |
| 151 |
}; |
| 152 |
namespace log { |
| 153 |
struct to_log_fun |
| 154 |
{ |
| 155 |
}; |
| 156 |
class value_extractor; |
| 157 |
template <typename, typename = value_extractor, typename = void, |
| 158 |
template <typename> class = actor> |
| 159 |
class attribute_actor; |
| 160 |
class attribute_terminal |
| 161 |
{ |
| 162 |
public: |
| 163 |
attribute_name m_name; |
| 164 |
attribute_name |
| 165 |
get_name () |
| 166 |
{ |
| 167 |
return m_name; |
| 168 |
} |
| 169 |
}; |
| 170 |
template <typename, typename, typename, template <typename> class ActorT> |
| 171 |
class attribute_actor : ActorT<attribute_terminal> |
| 172 |
{ |
| 173 |
public: |
| 174 |
typedef int value_type; |
| 175 |
attribute_name |
| 176 |
get_name () |
| 177 |
{ |
| 178 |
return this->proto_expr_.child0.get_name (); |
| 179 |
} |
| 180 |
}; |
| 181 |
template <typename AttributeValueT> |
| 182 |
attribute_actor<AttributeValueT> attr (attribute_name); // { dg-warning "used but never defined" } |
| 183 |
terminal<>::type stream; |
| 184 |
template <typename LeftT, typename ImplT> class attribute_output_terminal |
| 185 |
{ |
| 186 |
public: |
| 187 |
template <typename U> |
| 188 |
attribute_output_terminal (LeftT, attribute_name, ImplT, U); |
| 189 |
}; |
| 190 |
template <typename LeftT> struct make_output_expression |
| 191 |
{ |
| 192 |
typedef attribute_output_terminal<LeftT, to_log_fun> type; |
| 193 |
template <typename RightT> |
| 194 |
static type |
| 195 |
make (LeftT left, RightT &right) |
| 196 |
{ |
| 197 |
type (left, right.get_name (), to_log_fun (), 0); |
| 198 |
} |
| 199 |
}; |
| 200 |
template <typename, typename RightT, typename = typename RightT::value_type> |
| 201 |
struct make_output_actor; |
| 202 |
template <template <typename> class ActorT, typename LeftExprT, |
| 203 |
typename RightT, typename ValueT> |
| 204 |
struct make_output_actor<ActorT<LeftExprT>, RightT, ValueT> |
| 205 |
{ |
| 206 |
typedef make_output_expression<ActorT<LeftExprT> > make_expression; |
| 207 |
typedef ActorT<typename make_expression::type> type; |
| 208 |
static type |
| 209 |
make (ActorT<LeftExprT> left, RightT &right) |
| 210 |
{ |
| 211 |
type { make_expression::make (left, right) }; |
| 212 |
} |
| 213 |
}; |
| 214 |
template <typename LeftExprT, typename T, typename FallbackPolicyT, |
| 215 |
typename TagT> |
| 216 |
typename make_output_actor<actor<LeftExprT>, attribute_actor<TagT> >::type |
| 217 |
operator<<(actor<LeftExprT> left, |
| 218 |
attribute_actor<T, FallbackPolicyT, TagT> right) |
| 219 |
{ |
| 220 |
make_output_actor<actor<LeftExprT>, attribute_actor<T> >::make (left, right); |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
namespace logging = boost::log; |
| 225 |
namespace expr = logging; |
| 226 |
namespace { |
| 227 |
class my_class; |
| 228 |
} |
| 229 |
template <typename> struct default_formatting |
| 230 |
{ |
| 231 |
void test_method (); |
| 232 |
}; |
| 233 |
struct default_formatting_invoker |
| 234 |
{ |
| 235 |
static void |
| 236 |
run (void *) |
| 237 |
{ |
| 238 |
default_formatting<int> t; |
| 239 |
t.test_method (); |
| 240 |
} |
| 241 |
}; |
| 242 |
boost::auto_test_unit_registrar default_formatting_registrar56 ( |
| 243 |
boost::template_test_case_gen<default_formatting_invoker> (0, 0, 0)); |
| 244 |
template <typename CharT> |
| 245 |
void |
| 246 |
default_formatting<CharT>::test_method () |
| 247 |
{ |
| 248 |
expr::stream << expr::attr<my_class> (0); |
| 249 |
expr::stream << expr::attr<int> (0) << expr::attr<int> (0) |
| 250 |
<< expr::attr<int> (0); |
| 251 |
} |