1 // Build don't link:
2 // Special g++ Options: -ansi -pedantic-errors -Winline -O1
3
4 // Copyright (C) 2000 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 9 Mar 2000 <nathan@codesourcery.com>
6
7 // derived from a bug report by Benjamin Kosnik <bkoz@cygnus.com>
8
9 // __FUNCTION__ was erroneously causing us to issue a `cannot inline'
10 // diagnostic, even though we'd (a) inlined it, (b) been forced to issue an
11 // out of line body by taking it's address, (c) not used __FUNCTION__.
12
wibble()13 inline void wibble ()
14 {}
15
wobble()16 inline void wobble ()
17 {} // gets bogus error - cannot inline
18
19 void bar (void (*)());
20
bar1()21 void bar1 ()
22 {
23 wibble (); // can be inlined
24 void (*ptr) () = wobble; // force out of line issue
25
26 bar (ptr); // make sure we make use of it
27 }
28
29 struct B
30 {
mwibbleB31 void mwibble ()
32 {};
mwobbleB33 void mwobble ()
34 {}; // gets bogus error - cannot inline
35
swibbleB36 static void swibble ()
37 {};
swobbleB38 static void swobble ()
39 {}; // gets bogus error - cannot inline
40 };
41
42 void bar (void (B::*)());
43
bar2()44 void bar2 ()
45 {
46 B::swibble (); // can be inlined
47 void (*ptr) () = &B::swobble; // force out of line issue
48
49 bar (ptr); // make sure we make use of it
50 }
51
bar3(B * b)52 void bar3 (B *b)
53 {
54 b->mwibble (); // can be inlined
55 void (B::*ptr) () = &B::mwobble; // force out of line issue
56
57 bar (ptr); // make sure we make use of it
58 }
59
60 struct C
61 {
vwobbleC62 virtual void vwobble ()
63 {}; // gets bogus error - cannot inline
64 };
65
bar4()66 void bar4 ()
67 {
68 C c; // force issue of C's vtable etc
69 }
70