| 1 |
// PR c++/101029 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } allow [0] |
| 4 |
|
| 5 |
template <int __v> struct integral_constant { |
| 6 |
static constexpr int value = __v; |
| 7 |
typedef int value_type; |
| 8 |
constexpr operator value_type() { return __v; } |
| 9 |
}; |
| 10 |
template <bool __v> using __bool_constant = integral_constant<__v>; |
| 11 |
template <bool, typename> struct conditional; |
| 12 |
template <typename...> struct __and_; |
| 13 |
template <typename _B1, typename _B2, typename _B3, typename... _Bn> |
| 14 |
struct __and_<_B1, _B2, _B3, _Bn...> : conditional<_B1::value, _B1> {}; |
| 15 |
template <typename _Tp> |
| 16 |
constexpr integral_constant<true> __is_complete_or_unbounded(_Tp) { |
| 17 |
return {}; |
| 18 |
} |
| 19 |
template <typename _Tp> |
| 20 |
struct is_default_constructible : integral_constant<false> { |
| 21 |
static_assert(__is_complete_or_unbounded(_Tp{}), ""); |
| 22 |
}; |
| 23 |
template <typename _Tp, typename _Up> |
| 24 |
struct is_same : integral_constant<__is_same_as(_Tp, _Up)> {}; |
| 25 |
template <bool> struct enable_if; |
| 26 |
template <typename _Iffalse> struct conditional<false, _Iffalse> { |
| 27 |
typedef _Iffalse type; |
| 28 |
}; |
| 29 |
struct pair { |
| 30 |
template <typename _U1 = int, typename _U2 = int, |
| 31 |
typename enable_if<__and_<is_default_constructible<_U1>, _U2, |
| 32 |
int>::valuebool>::type> |
| 33 |
pair(); |
| 34 |
}; |
| 35 |
|
| 36 |
class BucketLogger; |
| 37 |
struct __shared_ptr_access { |
| 38 |
using element_type = BucketLogger; |
| 39 |
element_type *operator->(); |
| 40 |
}; |
| 41 |
struct DcpProducer { |
| 42 |
__shared_ptr_access logger; |
| 43 |
void bufferAcknowledgement(); |
| 44 |
}; |
| 45 |
struct atomic { |
| 46 |
atomic(long); |
| 47 |
}; |
| 48 |
inline namespace v7 { |
| 49 |
template <bool B, class, class F> |
| 50 |
using conditional_t = typename conditional<B, F>::type; |
| 51 |
template <typename> struct basic_string_view { basic_string_view(int, int); }; |
| 52 |
template <typename, typename> struct formatter; |
| 53 |
template <typename, typename> |
| 54 |
using has_formatter = |
| 55 |
__bool_constant<__is_constructible(void)>; |
| 56 |
struct fallback_formatter; |
| 57 |
template <typename Context> struct custom_value { |
| 58 |
using parse_context = typename Context::parse_context_type; |
| 59 |
void (*format)(const void *, parse_context &, Context &); |
| 60 |
}; |
| 61 |
template <typename Context> struct value { |
| 62 |
float float_value; |
| 63 |
custom_value<Context> custom; |
| 64 |
template <typename T> value(T) { |
| 65 |
custom.format = |
| 66 |
format_custom_arg<T, conditional_t<has_formatter<T, Context>::value, |
| 67 |
typename Context::formatter_type<T>, |
| 68 |
fallback_formatter>>; |
| 69 |
} |
| 70 |
template <typename, typename Formatter> |
| 71 |
static void format_custom_arg(const void *arg, |
| 72 |
typename Context::parse_context_type &, |
| 73 |
Context &ctx) { |
| 74 |
Formatter f; |
| 75 |
f.format(*static_cast<const int *>(arg), ctx); |
| 76 |
} |
| 77 |
}; |
| 78 |
enum { max_packed_args }; |
| 79 |
template <typename Context> struct basic_format_arg { value<Context> value_; }; |
| 80 |
template <typename Visitor, typename Context> |
| 81 |
void visit_format_arg(Visitor vis, Context arg) { |
| 82 |
vis(arg.value_.float_value); |
| 83 |
} |
| 84 |
template <typename Context, typename T> basic_format_arg<Context> make_arg(T); |
| 85 |
struct basic_format_context { |
| 86 |
using char_type = int; |
| 87 |
using parse_context_type = int; |
| 88 |
template <typename T> using formatter_type = formatter<T, char_type>; |
| 89 |
}; |
| 90 |
struct format_arg_store { |
| 91 |
using value_type = conditional_t<max_packed_args, basic_format_context, |
| 92 |
basic_format_arg<basic_format_context>>; |
| 93 |
value_type data_; |
| 94 |
}; |
| 95 |
template <typename... Args, typename S> |
| 96 |
auto make_args_checked(S, Args... args) -> format_arg_store { |
| 97 |
return {args...}; |
| 98 |
} |
| 99 |
struct basic_format_specs {}; |
| 100 |
template <typename Char, typename OutputIt, typename T> |
| 101 |
void write(OutputIt, T, Char) { |
| 102 |
if (is_same<T, float>()) |
| 103 |
; |
| 104 |
} |
| 105 |
struct arg_formatter_base { |
| 106 |
using iterator = int; |
| 107 |
using format_specs = basic_format_specs; |
| 108 |
iterator out_; |
| 109 |
template <typename T> void operator()(T value) { |
| 110 |
auto specs = format_specs(); |
| 111 |
write(out_, value, specs); |
| 112 |
} |
| 113 |
}; |
| 114 |
struct arg_formatter : arg_formatter_base { |
| 115 |
using context_type = basic_format_context; |
| 116 |
arg_formatter(context_type, int *, format_specs *); |
| 117 |
}; |
| 118 |
template <typename T, typename> struct formatter { |
| 119 |
template <typename FormatContext> void format(T val, FormatContext ctx) { |
| 120 |
using af = arg_formatter; |
| 121 |
basic_format_arg<FormatContext> __trans_tmp_2 = make_arg<FormatContext>(val); |
| 122 |
visit_format_arg(af(ctx, nullptr, &specs_), __trans_tmp_2); |
| 123 |
} |
| 124 |
basic_format_specs specs_; |
| 125 |
}; |
| 126 |
} // namespace v7 |
| 127 |
namespace level { |
| 128 |
enum level_enum { warn }; |
| 129 |
} |
| 130 |
struct BucketLogger { |
| 131 |
template <typename S, typename... Args> |
| 132 |
void log(level::level_enum, const S &, Args &&...); |
| 133 |
template <typename... Args> void warn(const char *, const Args &...); |
| 134 |
}; |
| 135 |
namespace v7 { |
| 136 |
struct fallback_formatter : formatter<basic_string_view<int>, int> { |
| 137 |
template <typename OutputIt> void format(int, OutputIt ctx) { |
| 138 |
basic_string_view<int> str(0, 0); |
| 139 |
formatter::format(str, ctx); |
| 140 |
} |
| 141 |
}; |
| 142 |
} // namespace v7 |
| 143 |
template <typename S, typename... Args> |
| 144 |
void BucketLogger::log(level::level_enum, const S &fmt, Args &&...args) { |
| 145 |
make_args_checked(fmt, args...); |
| 146 |
} |
| 147 |
template <typename... Args> |
| 148 |
void BucketLogger::warn(const char *fmt, const Args &...args) { |
| 149 |
log(level::warn, fmt, args...); |
| 150 |
} |
| 151 |
template <class KeyT> struct AtomicHashArray { |
| 152 |
static void create(); |
| 153 |
atomic isFull_; |
| 154 |
atomic numErases_; |
| 155 |
pair cells_[0]; |
| 156 |
AtomicHashArray(int, KeyT, KeyT, KeyT, double, unsigned); |
| 157 |
}; |
| 158 |
template <class KeyT> |
| 159 |
AtomicHashArray<KeyT>::AtomicHashArray(int, KeyT, KeyT, KeyT, double, unsigned) |
| 160 |
: isFull_(0), numErases_(0) {} |
| 161 |
template <class KeyT> void AtomicHashArray<KeyT>::create() { |
| 162 |
int c_4, capacity; |
| 163 |
double c_3; |
| 164 |
char c_2, c_1, c_0; |
| 165 |
AtomicHashArray(capacity, c_0, c_1, c_2, c_3, c_4); |
| 166 |
} |
| 167 |
int bufferAcknowledgement_vbucket; |
| 168 |
void DcpProducer::bufferAcknowledgement() { |
| 169 |
logger->warn("", bufferAcknowledgement_vbucket); |
| 170 |
} |
| 171 |
void (*makeStreamsMap_p)() = AtomicHashArray<char>::create; |