Skip to content

Commit e233158

Browse files
committed
c++, contracts: Improve contract locations.
Instead of: pre (x > 4) ^~~ We should now show: pre (x > 4) ^~~~~~~~~~ Which makes more sense when the complaint is about additional/missing conditions. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
1 parent 62a9c6a commit e233158

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gcc/cp/parser.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31490,6 +31490,8 @@ cp_parser_contract_attribute_spec (cp_parser *parser, tree attribute,
3149031490
/*consume_paren=*/false);
3149131491

3149231492
cp_token *last = cp_lexer_peek_token (parser->lexer);
31493+
location_t end = last->location;
31494+
loc = make_location (loc, loc, end);
3149331495

3149431496
if (!attr_mode)
3149531497
parens.require_close (parser);
@@ -31541,6 +31543,13 @@ cp_parser_contract_attribute_spec (cp_parser *parser, tree attribute,
3154131543
/* Revert (any) constification of the current class object. */
3154231544
current_class_ref = current_class_ref_copy;
3154331545

31546+
if (contract != error_mark_node)
31547+
{
31548+
location_t end = cp_lexer_peek_token (parser->lexer)->location;
31549+
loc = make_location (loc, loc, end);
31550+
SET_EXPR_LOCATION (contract, loc);
31551+
}
31552+
3154431553
/* For natural syntax, we eat the parens here. For the attribute
3154531554
syntax, it will be done one level up, we just need to skip to it. */
3154631555
if (!attr_mode)

0 commit comments

Comments
 (0)