> On 21 Aug 2026, at 13:14, Jason Merrill <[email protected]> wrote:
> 
> On 8/20/26 10:47 AM, Iain Sandoe wrote:
>> We made use of an attribute list throughout the project so that we
>> could continue to support cxx2a contracts in parallel.  Since those
>> have now been removed there is no longer any use and the attribute
>> lists are just unneccessary obfuscation.  Replace them with tree-vecs.
> 
> Missing ChangeLog
> 
>> @@ -1013,40 +1047,40 @@ start_function_contracts (tree fndecl)
>>      /* Check that the postcondition result name, if any, does not shadow a
>>       function parameter.  */
>> -  for (tree ca = get_fn_contract_specifiers (fndecl); ca; ca = TREE_CHAIN 
>> (ca))
>> -    if (POSTCONDITION_P (CONTRACT_STATEMENT (ca)))
>> -      if (tree id = POSTCONDITION_IDENTIFIER (CONTRACT_STATEMENT (ca)))
>> - {
>> -  if (id == error_mark_node)
>> -    {
>> -      CONTRACT_CONDITION (CONTRACT_STATEMENT (ca)) = error_mark_node;
>> -      continue;
>> -    }
>> -  tree r_name = tree_strip_any_location_wrapper (id);
>> -  if (TREE_CODE (id) == PARM_DECL)
>> -    r_name = DECL_NAME (id);
>> -  gcc_checking_assert (r_name && TREE_CODE (r_name) == IDENTIFIER_NODE);
>> -  tree seen = lookup_name (r_name);
>> -  if (seen
>> -      && TREE_CODE (seen) == PARM_DECL
>> -      && DECL_CONTEXT (seen) == fndecl)
>> -    {
>> +  if (tree specs = get_fn_contract_specifiers (fndecl))
>> +    for (tree ca : tree_vec_range (specs))
>> +      if (POSTCONDITION_P (ca))
>> + if (tree id = POSTCONDITION_IDENTIFIER (ca))
>> +  {
>> +    if (id == error_mark_node)
>> +      {
>> + CONTRACT_CONDITION (ca) = error_mark_node;
>> + continue;
>> +      }
>> +    tree r_name = tree_strip_any_location_wrapper (id);
>> +    if (TREE_CODE (id) == PARM_DECL)
>> +      r_name = DECL_NAME (id);
>> +    gcc_checking_assert (r_name && TREE_CODE (r_name) == IDENTIFIER_NODE);
> 
> The added indentation pushes this past 80 columns (caught by git gcc-style, 
> along with a couple of ".  " issues).
> 
>>  /* Update the entry for DECL in the map of contract specifiers with the
>> -  contracts in LIST. */
>> +  contracts in contracts. */
> 
> "contracts in contracts"?  Should be "contracts in CONTRACTS" or just 
> "...with CONTRACTS".
> 
> OK with those tweaks.

Somehow I sent the format-patch output - I had already done the changelog, but 
missed the
formatting glitches - thanks, applied as attached,
Iain

Attachment: 0001-c-contracts-Use-a-tree-vec-for-contract-specifiers.patch
Description: Binary data

Reply via email to