Module Name:    src
Committed By:   rillig
Date:           Sat Jan  2 17:17:00 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_035.c msg_035.exp msg_308.c
            msg_308.exp
        src/usr.bin/xlint/lint1: decl.c err.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_035.c \
    src/tests/usr.bin/xlint/lint1/msg_035.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_308.c \
    src/tests/usr.bin/xlint/lint1/msg_308.exp
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/err.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_035.c
diff -u src/tests/usr.bin/xlint/lint1/msg_035.c:1.4 src/tests/usr.bin/xlint/lint1/msg_035.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_035.c:1.4	Sat Jan  2 16:33:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_035.c	Sat Jan  2 17:17:00 2021
@@ -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;
Index: src/tests/usr.bin/xlint/lint1/msg_035.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_035.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_035.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_035.exp:1.4	Sat Jan  2 16:33:39 2021
+++ src/tests/usr.bin/xlint/lint1/msg_035.exp	Sat Jan  2 17:17:00 2021
@@ -12,6 +12,8 @@ msg_035.c(52): warning: illegal bit-fiel
 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]

Index: src/tests/usr.bin/xlint/lint1/msg_308.c
diff -u src/tests/usr.bin/xlint/lint1/msg_308.c:1.2 src/tests/usr.bin/xlint/lint1/msg_308.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_308.c:1.2	Sat Jan  2 16:55:45 2021
+++ src/tests/usr.bin/xlint/lint1/msg_308.c	Sat Jan  2 17:17:00 2021
@@ -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;
Index: src/tests/usr.bin/xlint/lint1/msg_308.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_308.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_308.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_308.exp:1.2	Sat Jan  2 16:55:45 2021
+++ src/tests/usr.bin/xlint/lint1/msg_308.exp	Sat Jan  2 17:17:00 2021
@@ -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]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.99 src/usr.bin/xlint/lint1/decl.c:1.100
--- src/usr.bin/xlint/lint1/decl.c:1.99	Sat Jan  2 16:33:39 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sat Jan  2 17:17:00 2021
@@ -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;
 	}
 

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.59 src/usr.bin/xlint/lint1/err.c:1.60
--- src/usr.bin/xlint/lint1/err.c:1.59	Wed Dec 30 01:33:30 2020
+++ src/usr.bin/xlint/lint1/err.c	Sat Jan  2 17:17:00 2021
@@ -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 */

Reply via email to