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 message 308 "Invalid type for ...



details:   https://anonhg.NetBSD.org/src/rev/7d4e0a2d10eb
branches:  trunk
changeset: 1017638:7d4e0a2d10eb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 02 17:17:00 2021 +0000

description:
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.

diffstat:

 tests/usr.bin/xlint/lint1/msg_035.c   |   4 ++--
 tests/usr.bin/xlint/lint1/msg_035.exp |   2 ++
 tests/usr.bin/xlint/lint1/msg_308.c   |  11 ++++-------
 tests/usr.bin/xlint/lint1/msg_308.exp |   4 +++-
 usr.bin/xlint/lint1/decl.c            |  12 +++++++-----
 usr.bin/xlint/lint1/err.c             |   6 +++---
 6 files changed, 21 insertions(+), 18 deletions(-)

diffs (119 lines):

diff -r 43f307c5afb8 -r 7d4e0a2d10eb tests/usr.bin/xlint/lint1/msg_035.c
--- a/tests/usr.bin/xlint/lint1/msg_035.c       Sat Jan 02 16:55:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_035.c       Sat Jan 02 17:17:00 2021 +0000
@@ -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 @@
        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;
diff -r 43f307c5afb8 -r 7d4e0a2d10eb tests/usr.bin/xlint/lint1/msg_035.exp
--- a/tests/usr.bin/xlint/lint1/msg_035.exp     Sat Jan 02 16:55:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_035.exp     Sat Jan 02 17:17:00 2021 +0000
@@ -12,6 +12,8 @@
 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]
diff -r 43f307c5afb8 -r 7d4e0a2d10eb tests/usr.bin/xlint/lint1/msg_308.c
--- a/tests/usr.bin/xlint/lint1/msg_308.c       Sat Jan 02 16:55:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_308.c       Sat Jan 02 17:17:00 2021 +0000
@@ -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;
diff -r 43f307c5afb8 -r 7d4e0a2d10eb tests/usr.bin/xlint/lint1/msg_308.exp
--- a/tests/usr.bin/xlint/lint1/msg_308.exp     Sat Jan 02 16:55:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_308.exp     Sat Jan 02 17:17:00 2021 +0000
@@ -1,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]
diff -r 43f307c5afb8 -r 7d4e0a2d10eb usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jan 02 16:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Jan 02 17:17:00 2021 +0000
@@ -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 @@
                        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;
        }
 
diff -r 43f307c5afb8 -r 7d4e0a2d10eb usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sat Jan 02 16:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sat Jan 02 17:17:00 2021 +0000
@@ -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 @@
        "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 */



Home | Main Index | Thread Index | Old Index