forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gcc-mirror#57 from NinaRanns/contract_client_check
Contract client check
- Loading branch information
Showing
6 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
gcc/testsuite/g++.dg/contracts/cpp26/definition-checks/virtual-func-no-def-check.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// check that an invocation of a virtual function through the base class does not | ||
// check contracts of the derived function, which are definition side contracts | ||
// { dg-do run } | ||
// { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr -fcontracts-nonattr-definition-check=off " } | ||
|
||
struct Base | ||
{ | ||
virtual int f(const int a){ return 0;}; | ||
}; | ||
|
||
struct Child : Base | ||
{ | ||
virtual int f(const int a) pre (a > 14) post(r:r >2){ return 1;} | ||
}; | ||
|
||
int fooBase(Base& b) | ||
{ | ||
return b.f(1); | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
Base b; | ||
Child c; | ||
|
||
fooBase (c); | ||
|
||
return 0; | ||
} |
31 changes: 31 additions & 0 deletions
31
gcc/testsuite/g++.dg/contracts/cpp26/definition-checks/virtual-func-no-def-check2.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// check that an invocation of a virtual function through the base class checks | ||
// the base class contracts when definition side contracts are turned off | ||
// { dg-do run } | ||
// { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr -fcontracts-nonattr-definition-check=off -fcontract-continuation-mode=on" } | ||
|
||
struct Base | ||
{ | ||
virtual int f(const int a) pre (a > 14) post(r:r > 2){ return 0;}; | ||
}; | ||
|
||
struct Child : Base | ||
{ | ||
virtual int f(const int a) pre (a > 14) post(r:r > 2){ return 1;} | ||
}; | ||
|
||
int fooBase(Base& b) | ||
{ | ||
return b.f(1); | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
Base b; | ||
Child c; | ||
|
||
fooBase (c); | ||
|
||
return 0; | ||
} | ||
// { dg-output "contract violation in function .*contract_wrapper at .*: a > 14.*(\n|\r\n|\r)" } | ||
// { dg-output "contract violation in function .*contract_wrapper at .*: r > 2.*(\n|\r\n|\r)" } |