Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/warn/pr83054.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
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 } |