| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: decl.c,v 1.195 2021/07/05 19:55:51 rillig Exp $ */ | | 1 | /* $NetBSD: decl.c,v 1.196 2021/07/10 12:10:39 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | | 5 | * Copyright (c) 1994, 1995 Jochen Pohl |
6 | * All Rights Reserved. | | 6 | * All Rights Reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #if HAVE_NBTOOL_CONFIG_H | | 35 | #if HAVE_NBTOOL_CONFIG_H |
36 | #include "nbtool_config.h" | | 36 | #include "nbtool_config.h" |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | #if defined(__RCSID) && !defined(lint) | | 40 | #if defined(__RCSID) && !defined(lint) |
41 | __RCSID("$NetBSD: decl.c,v 1.195 2021/07/05 19:55:51 rillig Exp $"); | | 41 | __RCSID("$NetBSD: decl.c,v 1.196 2021/07/10 12:10:39 rillig Exp $"); |
42 | #endif | | 42 | #endif |
43 | | | 43 | |
44 | #include <sys/param.h> | | 44 | #include <sys/param.h> |
45 | #include <limits.h> | | 45 | #include <limits.h> |
46 | #include <stdlib.h> | | 46 | #include <stdlib.h> |
47 | #include <string.h> | | 47 | #include <string.h> |
48 | | | 48 | |
49 | #include "lint1.h" | | 49 | #include "lint1.h" |
50 | | | 50 | |
51 | const char *unnamed = "<unnamed>"; | | 51 | const char *unnamed = "<unnamed>"; |
52 | | | 52 | |
53 | /* shared type structures for arithmetic types and void */ | | 53 | /* shared type structures for arithmetic types and void */ |
54 | static type_t *typetab; | | 54 | static type_t *typetab; |
| @@ -2420,45 +2420,47 @@ declare_argument(sym_t *sym, bool initfl | | | @@ -2420,45 +2420,47 @@ declare_argument(sym_t *sym, bool initfl |
2420 | } | | 2420 | } |
2421 | | | 2421 | |
2422 | if (!sym->s_arg) { | | 2422 | if (!sym->s_arg) { |
2423 | /* declared argument %s is missing */ | | 2423 | /* declared argument %s is missing */ |
2424 | error(53, sym->s_name); | | 2424 | error(53, sym->s_name); |
2425 | sym->s_arg = true; | | 2425 | sym->s_arg = true; |
2426 | } | | 2426 | } |
2427 | | | 2427 | |
2428 | if (initflg) { | | 2428 | if (initflg) { |
2429 | /* cannot initialize parameter: %s */ | | 2429 | /* cannot initialize parameter: %s */ |
2430 | error(52, sym->s_name); | | 2430 | error(52, sym->s_name); |
2431 | } | | 2431 | } |
2432 | | | 2432 | |
2433 | lint_assert(sym->s_type != NULL); | | 2433 | if (sym->s_type == NULL) /* for c(void()) */ |
| | | 2434 | sym->s_type = gettyp(VOID); |
| | | 2435 | |
2434 | if ((t = sym->s_type->t_tspec) == ARRAY) { | | 2436 | if ((t = sym->s_type->t_tspec) == ARRAY) { |
2435 | sym->s_type = derive_type(sym->s_type->t_subt, PTR); | | 2437 | sym->s_type = derive_type(sym->s_type->t_subt, PTR); |
2436 | } else if (t == FUNC) { | | 2438 | } else if (t == FUNC) { |
2437 | if (tflag) | | 2439 | if (tflag) |
2438 | /* a function is declared as an argument: %s */ | | 2440 | /* a function is declared as an argument: %s */ |
2439 | warning(50, sym->s_name); | | 2441 | warning(50, sym->s_name); |
2440 | sym->s_type = derive_type(sym->s_type, PTR); | | 2442 | sym->s_type = derive_type(sym->s_type, PTR); |
2441 | } else if (t == FLOAT) { | | 2443 | } else if (t == FLOAT) { |
2442 | if (tflag) | | 2444 | if (tflag) |
2443 | sym->s_type = gettyp(DOUBLE); | | 2445 | sym->s_type = gettyp(DOUBLE); |
2444 | } | | 2446 | } |
2445 | | | 2447 | |
2446 | if (dcs->d_inline) | | 2448 | if (dcs->d_inline) |
2447 | /* argument declared inline: %s */ | | 2449 | /* argument declared inline: %s */ |
2448 | warning(269, sym->s_name); | | 2450 | warning(269, sym->s_name); |
2449 | | | 2451 | |
2450 | /* | | 2452 | /* |
2451 | * Arguments must have complete types. lengths() prints the needed | | 2453 | * Arguments must have complete types. length() prints the needed |
2452 | * error messages (null dimension is impossible because arrays are | | 2454 | * error messages (null dimension is impossible because arrays are |
2453 | * converted to pointers). | | 2455 | * converted to pointers). |
2454 | */ | | 2456 | */ |
2455 | if (sym->s_type->t_tspec != VOID) | | 2457 | if (sym->s_type->t_tspec != VOID) |
2456 | (void)length(sym->s_type, sym->s_name); | | 2458 | (void)length(sym->s_type, sym->s_name); |
2457 | | | 2459 | |
2458 | sym->s_used = dcs->d_used; | | 2460 | sym->s_used = dcs->d_used; |
2459 | mark_as_set(sym); | | 2461 | mark_as_set(sym); |
2460 | | | 2462 | |
2461 | return sym; | | 2463 | return sym; |
2462 | } | | 2464 | } |
2463 | | | 2465 | |
2464 | void | | 2466 | void |