| 1 |
// { dg-do run } |
| 2 |
|
| 3 |
// Copyright (C) 2003 Free Software Foundation, Inc. |
| 4 |
// Contributed by Nathan Sidwell 6 Sep 2003 <[email protected]> |
| 5 |
// Origin: Volker Reichelt <[email protected]> |
| 6 |
|
| 7 |
// PR c++/11788 we failed to instantiate a decl, and we lost some side |
| 8 |
// effects |
| 9 |
|
| 10 |
static int flag = 0; |
| 11 |
|
| 12 |
template <typename> struct A |
| 13 |
{ |
| 14 |
A &active () { flag++; static A a; return a; } |
| 15 |
|
| 16 |
static void foo() {} |
| 17 |
|
| 18 |
static void bar () {} |
| 19 |
static void bar (int) {} |
| 20 |
|
| 21 |
int m; |
| 22 |
}; |
| 23 |
|
| 24 |
void (*baz ()) () |
| 25 |
{ |
| 26 |
A<int> a; |
| 27 |
return &a.active ().foo; |
| 28 |
} |
| 29 |
|
| 30 |
void (*boz ()) () |
| 31 |
{ |
| 32 |
A<int> a; |
| 33 |
return &a.active ().bar; |
| 34 |
} |
| 35 |
|
| 36 |
int *buz () |
| 37 |
{ |
| 38 |
A<int> a; |
| 39 |
|
| 40 |
return &a.active ().m; |
| 41 |
} |
| 42 |
|
| 43 |
int main () |
| 44 |
{ |
| 45 |
baz (); |
| 46 |
boz (); |
| 47 |
buz (); |
| 48 |
|
| 49 |
return flag != 3; |
| 50 |
} |