Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: fix parse error for type 'void (*)...



details:   https://anonhg.NetBSD.org/src/rev/0ce858b2941f
branches:  trunk
changeset: 1021981:0ce858b2941f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 28 11:09:35 2021 +0000

description:
lint: fix parse error for type 'void (*)[*]'

diffstat:

 tests/usr.bin/xlint/lint1/msg_155.c   |  7 +++----
 tests/usr.bin/xlint/lint1/msg_155.exp |  6 +++---
 usr.bin/xlint/lint1/cgram.y           |  9 ++++++---
 3 files changed, 12 insertions(+), 10 deletions(-)

diffs (80 lines):

diff -r 77147b355bcb -r 0ce858b2941f tests/usr.bin/xlint/lint1/msg_155.c
--- a/tests/usr.bin/xlint/lint1/msg_155.c       Mon Jun 28 10:29:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.c       Mon Jun 28 11:09:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_155.c,v 1.5 2021/06/28 10:29:05 rillig Exp $       */
+/*     $NetBSD: msg_155.c,v 1.6 2021/06/28 11:09:35 rillig Exp $       */
 # 3 "msg_155.c"
 
 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
@@ -8,7 +8,7 @@
 void c99_6_7_6_example_b(int *);
 void c99_6_7_6_example_c(int *[3]);
 void c99_6_7_6_example_d(int (*)[3]);
-void c99_6_7_6_example_e(int (*)[*]);  /* expect: syntax error ']' *//* FIXME */
+void c99_6_7_6_example_e(int (*)[*]);
 // FIXME: assertion "sym->s_type != NULL" failed in declare_argument at decl.c:2436
 // void c99_6_7_6_example_f(int *());
 void c99_6_7_6_example_g(int (*)(void));
@@ -34,8 +34,7 @@
        /* expect+1: 'pointer to array[3] of int' */
        c99_6_7_6_example_d(arg);
 
-       /* TODO: C99 says 'pointer to a variable length array of an unspecified number of ints' */
-       /* FIXME: no warning or error at all for an undefined function? */
+       /* expect+1: 'pointer to array[unknown_size] of int' */
        c99_6_7_6_example_e(arg);
 
        /* TODO: C99 says 'function with no parameter specification returning a pointer to int' */
diff -r 77147b355bcb -r 0ce858b2941f tests/usr.bin/xlint/lint1/msg_155.exp
--- a/tests/usr.bin/xlint/lint1/msg_155.exp     Mon Jun 28 10:29:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.exp     Mon Jun 28 11:09:35 2021 +0000
@@ -1,7 +1,7 @@
-msg_155.c(11): error: syntax error ']' [249]
 msg_155.c(25): warning: passing 'struct incompatible' to incompatible 'int', arg #1 [155]
 msg_155.c(28): warning: passing 'struct incompatible' to incompatible 'pointer to int', arg #1 [155]
 msg_155.c(32): warning: passing 'struct incompatible' to incompatible 'pointer to pointer to int', arg #1 [155]
 msg_155.c(35): warning: passing 'struct incompatible' to incompatible 'pointer to array[3] of int', arg #1 [155]
-msg_155.c(46): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
-msg_155.c(49): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
+msg_155.c(38): warning: passing 'struct incompatible' to incompatible 'pointer to array[unknown_size] of int', arg #1 [155]
+msg_155.c(45): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
+msg_155.c(48): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
diff -r 77147b355bcb -r 0ce858b2941f usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Mon Jun 28 10:29:05 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Mon Jun 28 11:09:35 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.246 2021/06/28 09:40:52 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.247 2021/06/28 11:09:35 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.246 2021/06/28 09:40:52 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.247 2021/06/28 11:09:35 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1462,7 +1462,7 @@
          }
        ;
 
-direct_abstract_declarator:
+direct_abstract_declarator:            /* C99 6.7.6 */
          T_LPAREN abstract_declarator T_RPAREN {
                $$ = $2;
          }
@@ -1478,6 +1478,9 @@
        | direct_abstract_declarator T_LBRACK T_RBRACK {
                $$ = add_array($1, false, 0);
          }
+       | direct_abstract_declarator T_LBRACK T_ASTERISK T_RBRACK { /* C99 */
+               $$ = add_array($1, false, 0);
+         }
        | direct_abstract_declarator T_LBRACK array_size T_RBRACK {
                $$ = add_array($1, true, to_int_constant($3, false));
          }



Home | Main Index | Thread Index | Old Index