131
|
1 // PR ipa/83054
|
|
2 // { dg-options "-O3 -Wsuggest-final-types" }
|
|
3 // { dg-do compile }
|
|
4
|
|
5 extern "C" int printf (const char *, ...);
|
|
6 struct foo // { dg-warning "final would enable devirtualization of 5 calls" }
|
|
7 {
|
|
8 static int count;
|
|
9 void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }
|
|
10 int x;
|
|
11 foo () {
|
|
12 x = count++;
|
|
13 printf("this %d = %x\n", x, (void *)this);
|
|
14 }
|
|
15 virtual ~foo () {
|
|
16 printf("this %d = %x\n", x, (void *)this);
|
|
17 --count;
|
|
18 }
|
|
19 };
|
|
20 int foo::count;
|
|
21
|
|
22
|
|
23 int main ()
|
|
24 {
|
|
25 {
|
|
26 foo array[3][3];
|
|
27 for (int i = 0; i < 3; i++)
|
|
28 {
|
|
29 for (int j = 0; j < 3; j++)
|
|
30 {
|
|
31 printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]);
|
|
32 }
|
|
33 }
|
|
34 // The count should be nine, if not, fail the test.
|
|
35 if (foo::count != 9)
|
|
36 return 1;
|
|
37 }
|
|
38 if (foo::count != 0)
|
|
39 return 1;
|
|
40 return 0;
|
|
41 }
|