1 // test that contracts on overriding functions are found correctly
3 // { dg-options "-std=c++2a -fcontracts -fcontract-continuation-mode=on" }
7 virtual int f(int a) [[ pre: a > 0 ]];
20 // defined out of line, explicit override
23 virtual int f(int a) override;
31 // defined out of line
42 // defined inline, explicitly override
45 virtual int f(int a) override
70 printf("Base: %d\n", b.f(-10));
71 printf("Child0: %d\n", c0.f(-10));
72 printf("Child1: %d\n", c1.f(-10));
73 printf("Child2: %d\n", c2.f(-10));
74 printf("Child3: %d\n", c3.f(-10));
75 printf("Child4: %d\n", c4.f(-10));
80 // { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } }
81 // { dg-output "contract violation in function Base::f at .*.C:7: .*(\n|\r\n|\r)" }
82 // { dg-output "Base: 0(\n|\r\n|\r)" }
83 // { dg-output "contract violation in function Base::f at .*.C:7: .*(\n|\r\n|\r)" }
84 // { dg-output "Child0: 0(\n|\r\n|\r)" }
85 // { dg-output "contract violation in function Child1::f at .*.C:7: .*(\n|\r\n|\r)" }
86 // { dg-output "Child1: 10(\n|\r\n|\r)" }
87 // { dg-output "contract violation in function Child2::f at .*.C:7: .*(\n|\r\n|\r)" }
88 // { dg-output "Child2: 20(\n|\r\n|\r)" }
89 // { dg-output "contract violation in function Child3::f at .*.C:7: .*(\n|\r\n|\r)" }
90 // { dg-output "Child3: 30(\n|\r\n|\r)" }
91 // { dg-output "contract violation in function Child4::f at .*.C:7: .*(\n|\r\n|\r)" }
92 // { dg-output "Child4: 40(\n|\r\n|\r)" }