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

This commit is contained in:
rillig 2021-06-28 11:09:35 +00:00
parent 8b3bb5df80
commit d8a3f2eb44
3 changed files with 12 additions and 10 deletions

View File

@ -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_a(int);
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 @@ provoke_error_messages(struct incompatible arg)
/* 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' */

View File

@ -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]

View File

@ -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 @@ abstract_declarator: /* C99 6.7.6 */
}
;
direct_abstract_declarator:
direct_abstract_declarator: /* C99 6.7.6 */
T_LPAREN abstract_declarator T_RPAREN {
$$ = $2;
}
@ -1478,6 +1478,9 @@ direct_abstract_declarator:
| 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));
}