Skip to content

Commit 2579569

Browse files
committed
renaming the flag, fixing the artificial parameters in remapping
1 parent 438904c commit 2579569

File tree

6 files changed

+25
-335
lines changed

6 files changed

+25
-335
lines changed

gcc/c-family/c.opt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,11 +1978,11 @@ EnumValue
19781978
Enum(contract_inheritance) String(P2900R13) Value(1)
19791979

19801980
EnumValue
1981-
Enum(contract_inheritance) String(Ville) Value(2)
1981+
Enum(contract_inheritance) String(P3653) Value(2)
19821982

19831983
fcontracts-nonattr-inheritance-mode=
19841984
C++ Joined RejectNegative Enum(contract_inheritance) Var(flag_contract_nonattr_inheritance_mode) Init(1)
1985-
-fcontracts-nonattr-inheritance-mode=[none|P2900R13|Ville] Select how contracts are inherited for virtual functions
1985+
-fcontracts-nonattr-inheritance-mode=[none|P2900R13|P3653] Select how contracts are inherited for virtual functions
19861986

19871987
Wsuggest-explicit-contract
19881988
C++ ObjC++ Var(suggest_explicit_contract) Warning

gcc/cp/contracts.cc

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,12 +1080,14 @@ remap_contract (tree src, tree dst, tree contract, bool duplicate_p)
10801080
bool do_remap = false;
10811081

10821082
/* Insert parameter remappings. */
1083-
if (TREE_CODE (src) == FUNCTION_DECL)
1084-
src = DECL_ARGUMENTS (src);
1085-
if (TREE_CODE (dst) == FUNCTION_DECL)
1086-
dst = DECL_ARGUMENTS (dst);
1083+
gcc_assert(TREE_CODE (src) == FUNCTION_DECL);
1084+
gcc_assert(TREE_CODE (dst) == FUNCTION_DECL);
10871085

1088-
for (tree sp = src, dp = dst;
1086+
int src_num_artificial_args = num_artificial_parms_for (src);
1087+
int dst_num_artificial_args = num_artificial_parms_for (dst);
1088+
1089+
1090+
for (tree sp = DECL_ARGUMENTS (src), dp = DECL_ARGUMENTS (dst);
10891091
sp || dp;
10901092
sp = DECL_CHAIN (sp), dp = DECL_CHAIN (dp))
10911093
{
@@ -1109,6 +1111,20 @@ remap_contract (tree src, tree dst, tree contract, bool duplicate_p)
11091111

11101112
insert_decl_map (&id, sp, dp);
11111113
do_remap = true;
1114+
1115+
/* First artificial arg is *this. We want to remap that. However, we
1116+
want to skip _in_charge param and __vtt_parm. Do so now. */
1117+
if (src_num_artificial_args > 0)
1118+
{
1119+
while (--src_num_artificial_args,src_num_artificial_args > 0)
1120+
sp = DECL_CHAIN (sp);
1121+
}
1122+
if (dst_num_artificial_args > 0)
1123+
{
1124+
while (--dst_num_artificial_args,dst_num_artificial_args > 0)
1125+
dp = DECL_CHAIN (dp);
1126+
}
1127+
11121128
}
11131129
if (!do_remap)
11141130
return;

gcc/cp/contracts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ enum contract_inheritance
6161
{
6262
CONTRACT_INHERITANCE_NONE = 0,
6363
CONTRACT_INHERITANCE_P2900R13 = 1,
64-
CONTRACT_INHERITANCE_VILLE = 2,
64+
CONTRACT_INHERITANCE_P3653 = 2,
6565
};
6666

6767
/* True if the contract is unchecked. */

gcc/cp/search.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ check_override_contracts (tree fndecl)
22302230
{
22312231

22322232
if (!flag_contracts || !flag_contracts_nonattr
2233-
|| flag_contract_nonattr_inheritance_mode != CONTRACT_INHERITANCE_VILLE )
2233+
|| flag_contract_nonattr_inheritance_mode != CONTRACT_INHERITANCE_P3653 )
22342234
return;
22352235

22362236
/* A constructor for a class T does not override a function T

gcc/testsuite/g++.dg/contracts/cpp26/virtual_func_ville.C

Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
 (0)