C99 testsuite readiness: Compile more tests with -std=gnu89
[official-gcc.git] / gcc / testsuite / g++.dg / pr94314.C
blob72467127feaae9a6be0de7044cd73d77b42d068b
1 /* PR c++/94314.  */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -fdump-tree-cddce-details -fdelete-null-pointer-checks" } */
5 struct A
7   __attribute__((malloc,noinline))
8   static void* operator new(__SIZE_TYPE__ sz)
9   {
10     ++count;
11     return ::operator new(sz);
12   }
14   static void operator delete(void* ptr)
15   {
16     --count;
17     ::operator delete(ptr);
18   }
20   static int count;
23 int A::count = 0;
25 struct B
27   __attribute__((malloc,noinline))
28   static void* operator new(__SIZE_TYPE__ sz)
29   {
30     ++count;
31     return ::operator new(sz);
32   }
34   __attribute__((noinline))
35   static void operator delete(void* ptr)
36   {
37     --count;
38     ::operator delete(ptr);
39   }
41   static int count;
44 int B::count = 0;
46 struct C
48   static void* operator new(__SIZE_TYPE__ sz)
49   {
50     ++count;
51     return ::operator new(sz);
52   }
54   static void operator delete(void* ptr)
55   {
56     --count;
57     ::operator delete(ptr);
58   }
60   static int count;
63 int C::count = 0;
65 int main(){
66   delete new A;
67   if (A::count != 0)
68     __builtin_abort ();
70   delete new B;
71   if (B::count != 0)
72     __builtin_abort ();
74   delete new C;
75   if (C::count != 0)
76     __builtin_abort ();
78   return 0;
81 /* { dg-final { scan-tree-dump-not "Deleting : operator delete" "cddce1"} } */
82 /* { dg-final { scan-tree-dump-not "Deleting : B::operator delete" "cddce1"} } */