re PR c/71362 (Wrong position for "error: size of unnamed array is negative")

PR c/71362
	* c-parser.c (c_parser_direct_declarator): Set location.

	* gcc.dg/pr71362.c: New test.

From-SVN: r237155
This commit is contained in:
Marek Polacek 2016-06-06 21:15:07 +00:00 committed by Marek Polacek
parent 6f5bcd2400
commit 1f40cff379
4 changed files with 21 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2016-06-06 Marek Polacek <polacek@redhat.com>
PR c/71362
* c-parser.c (c_parser_direct_declarator): Set location.
2016-06-06 Marek Polacek <polacek@redhat.com>
* c-typeck.c (comptypes_internal): Handle comparisons of

View File

@ -3430,6 +3430,7 @@ c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
&& c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
{
struct c_declarator *inner = build_id_declarator (NULL_TREE);
inner->id_loc = c_parser_peek_token (parser)->location;
return c_parser_direct_declarator_inner (parser, *seen_id, inner);
}

View File

@ -1,3 +1,8 @@
2016-06-06 Marek Polacek <polacek@redhat.com>
PR c/71362
* gcc.dg/pr71362.c: New test.
2016-06-06 Jakub Jelinek <jakub@redhat.com>
Patrick Palka <ppalka@gcc.gnu.org>

View File

@ -0,0 +1,10 @@
/* PR c/71362 */
/* { dg-do compile } */
extern void foo (int[-1]); /* { dg-error "21:size of unnamed array is negative" } */
int
bar (void)
{
123 + sizeof (int[-1]); /* { dg-error "20:size of unnamed array is negative" } */
}