1 // { dg-do compile }
2
3 extern "C" class WvFastString;
4 typedef WvFastString& WvStringParm;
5 struct WvFastString {
6 ~WvFastString();
7 operator char* () {}
8 };
9 class WvString : WvFastString {};
10 class WvAddr {};
11 class WvIPAddr : WvAddr {};
12 struct WvIPNet : WvIPAddr {
is_defaultWvIPNet13 bool is_default() {}
14 };
15 template<class T, bool> struct WvTraits_Helper {
releaseWvTraits_Helper16 static void release(T *obj) {
17 delete obj;
18 }
19 };
20 template<class From> struct WvTraits {
releaseWvTraits21 static void release(From *obj) {
22 WvTraits_Helper<From, 0>::release(obj);
23 }
24 };
25 struct WvLink {
26 void *data;
27 WvLink *next;
28 bool autofree;
WvLinkWvLink29 WvLink(bool, int) : autofree() {}
get_autofreeWvLink30 bool get_autofree() {}
31
unlinkWvLink32 void unlink() {
33 delete this;
34 }
35 };
36 struct WvListBase {
37 WvLink head, *tail;
WvListBaseWvListBase38 WvListBase() : head(0, 0) {}
39 };
40 template<class T> struct WvList : WvListBase {
~WvListWvList41 ~WvList() {
42 zap();
43 }
44
45 void zap(bool destroy = 1) {
46 while (head.next) unlink_after(&head, destroy);
47 }
48
unlink_afterWvList49 void unlink_after(WvLink *after, bool destroy) {
50 WvLink *next = 0;
51 T *obj = (destroy && next->get_autofree()) ?
52 static_cast<T*>(next->data) : 0;
53
54 if (tail) tail = after;
55 next->unlink();
56 WvTraits<T>::release(obj);
57 }
58 };
59 typedef WvList<WvString>WvStringListBase;
60 class WvStringList : WvStringListBase {};
61 class WvSubProc {
62 WvStringList last_args, env;
63 };
addroute(WvIPNet & dest,WvStringParm table)64 void addroute(WvIPNet& dest, WvStringParm table) {
65 if (dest.is_default() || (table != "default")) WvSubProc checkProc;
66 }
67