@@ -31861,6 +31861,51 @@ cp_parser_should_constify_contract (const contract_modifier& modifier)
31861
31861
return should_constify;
31862
31862
}
31863
31863
31864
+ /* Parse an inherited contract. */
31865
+
31866
+ static tree
31867
+ cp_parse_inherited_contract (cp_parser *parser)
31868
+ {
31869
+ cp_token *token = cp_lexer_consume_token (parser->lexer);
31870
+ location_t loc = token->location;
31871
+
31872
+ gcc_checking_assert(token->type == CPP_KEYWORD
31873
+ && token->keyword == RID_INHERITED);
31874
+
31875
+ matching_parens parens;
31876
+ parens.require_open (parser);
31877
+
31878
+ if (flag_contracts_on_virtual_functions != CONTRACTS_ON_VIRTUALS_P3653)
31879
+ {
31880
+ error_at (loc, "inherited contracts are only available with"
31881
+ " %<-fcontracts-on-virtual-functions=P3653%>");
31882
+
31883
+ cp_parser_skip_to_closing_parenthesis_1 (parser, /*recovering=*/true,
31884
+ CPP_CLOSE_PAREN,
31885
+ /*consume_paren=*/true);
31886
+ return error_mark_node;
31887
+ }
31888
+
31889
+ /* Otherwise, look for the class-name. */
31890
+ tree type = cp_parser_class_name (parser,
31891
+ /*typename_keyword_p=*/true,
31892
+ /*template_keyword_p=*/false,
31893
+ none_type,
31894
+ /*check_dependency_p=*/false,
31895
+ /*class_head_p=*/false,
31896
+ /*is_declaration=*/false);
31897
+ type = TREE_TYPE (type);
31898
+ /* ": T...[constant-expression]" is a C++26 pack-index-specifier. */
31899
+ if (cp_parser_next_tokens_are_pack_index_p (parser))
31900
+ type = cp_parser_pack_index (parser, type);
31901
+
31902
+ cp_parser_skip_to_closing_parenthesis_1 (parser,
31903
+ /*recovering=*/true,
31904
+ CPP_CLOSE_PAREN,
31905
+ /*consume_paren=*/true);
31906
+ return error_mark_node;
31907
+ }
31908
+
31864
31909
/* Parse a natural syntax contract specifier seq.
31865
31910
31866
31911
function-contract-specifier :
@@ -31901,6 +31946,11 @@ cp_parser_function_contract_specifier (cp_parser *parser)
31901
31946
location_t loc = token->location;
31902
31947
bool postcondition_p = is_attribute_p ("post", contract_name);
31903
31948
31949
+ token = cp_lexer_peek_token (parser->lexer);
31950
+
31951
+ if (token->type == CPP_KEYWORD && token->keyword == RID_INHERITED)
31952
+ return cp_parse_inherited_contract(parser);
31953
+
31904
31954
/* Parse experimental modifiers on C++26 contracts. */
31905
31955
contract_modifier modifier
31906
31956
= cp_parser_function_contract_modifier_opt (parser);
0 commit comments