Skip to content

Commit 1d12e63

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 <[email protected]>
1 parent 6baca63 commit 1d12e63

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
@@ -31534,6 +31534,8 @@ cp_parser_contract_attribute_spec (cp_parser *parser, tree attribute,
3153431534
/*consume_paren=*/false);
3153531535

3153631536
cp_token *last = cp_lexer_peek_token (parser->lexer);
31537+
location_t end = last->location;
31538+
loc = make_location (loc, loc, end);
3153731539

3153831540
if (!attr_mode)
3153931541
parens.require_close (parser);
@@ -31585,6 +31587,13 @@ cp_parser_contract_attribute_spec (cp_parser *parser, tree attribute,
3158531587
/* Revert (any) constification of the current class object. */
3158631588
current_class_ref = current_class_ref_copy;
3158731589

31590+
if (contract != error_mark_node)
31591+
{
31592+
location_t end = cp_lexer_peek_token (parser->lexer)->location;
31593+
loc = make_location (loc, loc, end);
31594+
SET_EXPR_LOCATION (contract, loc);
31595+
}
31596+
3158831597
/* For natural syntax, we eat the parens here. For the attribute
3158931598
syntax, it will be done one level up, we just need to skip to it. */
3159031599
if (!attr_mode)

0 commit comments

Comments
 (0)