From 1f40cff37998535a8f6f3eb6989327d8be3c8efb Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 6 Jun 2016 21:15:07 +0000 Subject: [PATCH] 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 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-parser.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr71362.c | 10 ++++++++++ 4 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr71362.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f0b03d2c8d7..3b7feaa3373 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-06-06 Marek Polacek + + PR c/71362 + * c-parser.c (c_parser_direct_declarator): Set location. + 2016-06-06 Marek Polacek * c-typeck.c (comptypes_internal): Handle comparisons of diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index bca8653f8d8..799a473bae9 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 29f5150e023..e292f547f39 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-06 Marek Polacek + + PR c/71362 + * gcc.dg/pr71362.c: New test. + 2016-06-06 Jakub Jelinek Patrick Palka diff --git a/gcc/testsuite/gcc.dg/pr71362.c b/gcc/testsuite/gcc.dg/pr71362.c new file mode 100644 index 00000000000..fd9cd6a20d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71362.c @@ -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" } */ +} -- 2.30.2