lint: fix message 308 "Invalid type for _Complex"

Previously, lint aborted since it didn't expect tspec_name to be called
with NOTSPEC, which at that point was the only possible value of
dcs->d_cmod.
This commit is contained in:
rillig 2021-01-02 17:17:00 +00:00
parent 4b1f579b14
commit 5827a84bf2
6 changed files with 21 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg_035.c,v 1.4 2021/01/02 16:33:39 rillig Exp $ */
/* $NetBSD: msg_035.c,v 1.5 2021/01/02 17:17:00 rillig Exp $ */
# 3 "msg_035.c"
// Test for message: illegal bit-field type [35]
@ -54,7 +54,7 @@ struct example {
void *pointer_flag: 1;
unsigned int array_flag[4]: 1;
example_function function_flag: 1;
// FIXME: aborts: _Complex complex_flag: 1;
_Complex complex_flag: 1;
float _Complex float_complex_flag: 1;
double _Complex double_complex_flag: 1;
long double _Complex long_double_complex_flag: 1;

View File

@ -12,6 +12,8 @@ msg_035.c(52): warning: illegal bit-field type [35]
msg_035.c(54): warning: illegal bit-field type [35]
msg_035.c(55): warning: illegal bit-field type [35]
msg_035.c(56): warning: illegal bit-field type [35]
msg_035.c(57): Invalid type for _Complex [308]
msg_035.c(57): warning: illegal bit-field type [35]
msg_035.c(58): warning: illegal bit-field type [35]
msg_035.c(59): warning: illegal bit-field type [35]
msg_035.c(60): warning: illegal bit-field type [35]

View File

@ -1,13 +1,10 @@
/* $NetBSD: msg_308.c,v 1.2 2021/01/02 16:55:45 rillig Exp $ */
/* $NetBSD: msg_308.c,v 1.3 2021/01/02 17:17:00 rillig Exp $ */
# 3 "msg_308.c"
// Test for message: Invalid type %s for _Complex [308]
// Test for message: Invalid type for _Complex [308]
float _Complex float_complex;
double _Complex double_complex;
long double _Complex long_double_complex;
// FIXME: aborts: _Complex plain_complex;
// FIXME: aborts: int _Complex int_complex;
TODO: "Add example code that triggers the above message."
TODO: "Add example code that almost triggers the above message."
_Complex plain_complex;
int _Complex int_complex;

View File

@ -1 +1,3 @@
msg_308.c(12): syntax error ':' [249]
msg_308.c(9): Invalid type for _Complex [308]
msg_308.c(10): Invalid type for _Complex [308]
msg_308.c(10): illegal type combination [4]

View File

@ -1,4 +1,4 @@
/* $NetBSD: decl.c,v 1.99 2021/01/02 16:33:39 rillig Exp $ */
/* $NetBSD: decl.c,v 1.100 2021/01/02 17:17:00 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: decl.c,v 1.99 2021/01/02 16:33:39 rillig Exp $");
__RCSID("$NetBSD: decl.c,v 1.100 2021/01/02 17:17:00 rillig Exp $");
#endif
#include <sys/param.h>
@ -303,9 +303,11 @@ add_type(type_t *tp)
t = FCOMPLEX;
else if (dcs->d_cmod == DOUBLE)
t = DCOMPLEX;
else
/* Invalid type %s for _Complex */
error(308, tspec_name(dcs->d_cmod));
else {
/* Invalid type for _Complex */
error(308);
t = DCOMPLEX; /* just as a fallback */
}
dcs->d_cmod = NOTSPEC;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.59 2020/12/30 01:33:30 rillig Exp $ */
/* $NetBSD: err.c,v 1.60 2021/01/02 17:17:00 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: err.c,v 1.59 2020/12/30 01:33:30 rillig Exp $");
__RCSID("$NetBSD: err.c,v 1.60 2021/01/02 17:17:00 rillig Exp $");
#endif
#include <sys/types.h>
@ -367,7 +367,7 @@ const char *msgs[] = {
"ANSI C forbids conversion of %s to %s, op %s", /* 305 */
"constant truncated by conversion, op %s", /* 306 */
"static variable %s set but not used", /* 307 */
"Invalid type %s for _Complex", /* 308 */
"Invalid type for _Complex", /* 308 */
"extra bits set to 0 in conversion of '%s' to '%s', op %s", /* 309 */
"symbol renaming can't be used on function arguments", /* 310 */
"symbol renaming can't be used on automatic variables", /* 311 */