Debian Codegraph @

gcc/testsuite/g++.dg/warn/pr83054.C

raw
1 // PR ipa/83054
2 // { dg-options "-O3 -Wsuggest-final-types" }
3 // { dg-do compile }
4
5 // A throwing dtor in C++98 mode changes the warning.
6 #if __cplusplus < 201100L
7 #define NOTHROW throw()
8 #else
9 #define NOTHROW noexcept
10 #endif
11
12 extern "C" int printf (const char *, ...);
13 struct foo
14 {
15 static int count;
16 void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }
17 int x;
18 foo () {
19 x = count++;
20 printf("this %d = %x\n", x, (void *)this);
21 }
22 virtual ~foo () NOTHROW {
23 printf("this %d = %x\n", x, (void *)this);
24 --count;
25 }
26 };
27 int foo::count;
28
29
30 int main ()
31 {
32 {
33 foo array[3][3];
34 for (int i = 0; i < 3; i++)
35 {
36 for (int j = 0; j < 3; j++)
37 {
38 printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]);
39 }
40 }
41 // The count should be nine, if not, fail the test.
42 if (foo::count != 9)
43 return 1;
44 }
45 if (foo::count != 0)
46 return 1;
47 return 0;
48 }