re PR c/71362 (Wrong position for "error: size of unnamed array is negative")
authorMarek Polacek <polacek@redhat.com>
Mon, 6 Jun 2016 21:15:07 +0000 (21:15 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 6 Jun 2016 21:15:07 +0000 (21:15 +0000)
PR c/71362
* c-parser.c (c_parser_direct_declarator): Set location.

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

From-SVN: r237155

gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr71362.c [new file with mode: 0644]

index f0b03d2c8d743c9ea4fff1b02daaf715e278331d..3b7feaa33736628c4d7db5d2fc1918d125fd65fb 100644 (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
index bca8653f8d8500dc2564fdc94af5dc8f04b178aa..799a473bae9aadac559574e9f98dcaa54e9550d2 100644 (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);
     }
 
index 29f5150e02309b769be4e8df59b2405142de0f60..e292f547f39eabf341edc486650ed8b4b4a02206 100644 (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>
 
diff --git a/gcc/testsuite/gcc.dg/pr71362.c b/gcc/testsuite/gcc.dg/pr71362.c
new file mode 100644 (file)
index 0000000..fd9cd6a
--- /dev/null
@@ -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" } */
+}