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: reduce indentation in tdeferr
details: https://anonhg.NetBSD.org/src/rev/40b2e2e447d3
branches: trunk
changeset: 1023355:40b2e2e447d3
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Sep 04 13:45:36 2021 +0000
description:
lint: reduce indentation in tdeferr
No functional change.
diffstat:
tests/usr.bin/xlint/lint1/msg_005.c | 27 ++++++-
tests/usr.bin/xlint/lint1/msg_005.exp | 6 +-
usr.bin/xlint/common/tyname.c | 5 +-
usr.bin/xlint/lint1/decl.c | 125 +++++++++++----------------------
4 files changed, 76 insertions(+), 87 deletions(-)
diffs (221 lines):
diff -r 259edb171207 -r 40b2e2e447d3 tests/usr.bin/xlint/lint1/msg_005.c
--- a/tests/usr.bin/xlint/lint1/msg_005.c Sat Sep 04 13:36:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_005.c Sat Sep 04 13:45:36 2021 +0000
@@ -1,8 +1,29 @@
-/* $NetBSD: msg_005.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */
+/* $NetBSD: msg_005.c,v 1.4 2021/09/04 13:45:37 rillig Exp $ */
# 3 "msg_005.c"
// Test for message: modifying typedef with '%s'; only qualifiers allowed [5]
typedef int number;
-number long long_variable; /* expect: 5 */
-number const const_variable;
+
+/* expect+1: warning: modifying typedef with 'signed'; only qualifiers allowed [5] */
+typedef number signed signed_number;
+
+/* expect+1: warning: modifying typedef with 'unsigned'; only qualifiers allowed [5] */
+typedef number unsigned unsigned_number;
+
+/* expect+1: warning: modifying typedef with 'short'; only qualifiers allowed [5] */
+typedef number short short_number;
+
+/* expect+1: modifying typedef with 'long'; only qualifiers allowed [5] */
+typedef number long long_number;
+
+/*
+ * If the type qualifier comes first, the following name is interpreted as a
+ * new name, not as the one referring to the typedef. This makes the above
+ * type modifications even more obscure.
+ */
+/* expect+1: error: syntax error 'prefix_long_number' [249] */
+typedef long number prefix_long_number;
+
+/* Type qualifiers are OK. */
+typedef number const const_number;
diff -r 259edb171207 -r 40b2e2e447d3 tests/usr.bin/xlint/lint1/msg_005.exp
--- a/tests/usr.bin/xlint/lint1/msg_005.exp Sat Sep 04 13:36:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_005.exp Sat Sep 04 13:45:36 2021 +0000
@@ -1,1 +1,5 @@
-msg_005.c(7): warning: modifying typedef with 'long'; only qualifiers allowed [5]
+msg_005.c(9): warning: modifying typedef with 'signed'; only qualifiers allowed [5]
+msg_005.c(12): warning: modifying typedef with 'unsigned'; only qualifiers allowed [5]
+msg_005.c(15): warning: modifying typedef with 'short'; only qualifiers allowed [5]
+msg_005.c(18): warning: modifying typedef with 'long'; only qualifiers allowed [5]
+msg_005.c(26): error: syntax error 'prefix_long_number' [249]
diff -r 259edb171207 -r 40b2e2e447d3 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c Sat Sep 04 13:36:07 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c Sat Sep 04 13:45:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tyname.c,v 1.46 2021/08/31 23:49:21 rillig Exp $ */
+/* $NetBSD: tyname.c,v 1.47 2021/09/04 13:45:36 rillig Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.46 2021/08/31 23:49:21 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.47 2021/09/04 13:45:36 rillig Exp $");
#endif
#include <limits.h>
@@ -147,6 +147,7 @@
buf_add(buf, num);
}
+/* XXX: at least partly redundant with ttab[t].tt_name */
const char *
tspec_name(tspec_t t)
{
diff -r 259edb171207 -r 40b2e2e447d3 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Sep 04 13:36:07 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Sep 04 13:45:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.232 2021/09/04 13:27:59 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.233 2021/09/04 13:45:37 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.232 2021/09/04 13:27:59 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.233 2021/09/04 13:45:37 rillig Exp $");
#endif
#include <sys/param.h>
@@ -443,88 +443,51 @@
t2 = td->t_tspec;
- switch (t) {
- case SIGNED:
- case UNSIGN:
- if (t2 == CHAR || t2 == SHORT || t2 == INT || t2 == LONG ||
- t2 == QUAD) {
- if (!tflag)
- /* modifying typedef with '%s'; only ... */
- warning(5, ttab[t].tt_name);
- td = dup_type(gettyp(merge_signedness(t2, t)));
- td->t_typedef = true;
- return td;
- }
- break;
- case SHORT:
- if (t2 == INT || t2 == UINT) {
- /* modifying typedef with '%s'; only qualifiers ... */
- warning(5, "short");
- td = dup_type(gettyp(t2 == INT ? SHORT : USHORT));
- td->t_typedef = true;
- return td;
+ if ((t == SIGNED || t == UNSIGN) &&
+ (t2 == CHAR || t2 == SHORT || t2 == INT ||
+ t2 == LONG || t2 == QUAD)) {
+ if (!tflag)
+ /* modifying typedef with '%s'; only qualifiers... */
+ warning(5, tspec_name(t));
+ td = dup_type(gettyp(merge_signedness(t2, t)));
+ td->t_typedef = true;
+ return td;
+ }
+
+ if (t == SHORT && (t2 == INT || t2 == UINT)) {
+ /* modifying typedef with '%s'; only qualifiers allowed */
+ warning(5, "short");
+ td = dup_type(gettyp(t2 == INT ? SHORT : USHORT));
+ td->t_typedef = true;
+ return td;
+ }
+
+ if (t == LONG &&
+ (t2 == INT || t2 == UINT || t2 == LONG || t2 == ULONG ||
+ t2 == FLOAT || t2 == DOUBLE || t2 == DCOMPLEX)) {
+ /* modifying typedef with '%s'; only qualifiers allowed */
+ warning(5, "long");
+ if (t2 == INT) {
+ td = gettyp(LONG);
+ } else if (t2 == UINT) {
+ td = gettyp(ULONG);
+ } else if (t2 == LONG) {
+ td = gettyp(QUAD);
+ } else if (t2 == ULONG) {
+ td = gettyp(UQUAD);
+ } else if (t2 == FLOAT) {
+ td = gettyp(DOUBLE);
+ } else if (t2 == DOUBLE) {
+ td = gettyp(LDOUBLE);
+ } else if (t2 == DCOMPLEX) {
+ td = gettyp(LCOMPLEX);
}
- break;
- case LONG:
- if (t2 == INT || t2 == UINT || t2 == LONG || t2 == ULONG ||
- t2 == FLOAT || t2 == DOUBLE || t2 == DCOMPLEX) {
- /* modifying typedef with '%s'; only qualifiers ... */
- warning(5, "long");
- if (t2 == INT) {
- td = gettyp(LONG);
- } else if (t2 == UINT) {
- td = gettyp(ULONG);
- } else if (t2 == LONG) {
- td = gettyp(QUAD);
- } else if (t2 == ULONG) {
- td = gettyp(UQUAD);
- } else if (t2 == FLOAT) {
- td = gettyp(DOUBLE);
- } else if (t2 == DOUBLE) {
- td = gettyp(LDOUBLE);
- } else if (t2 == DCOMPLEX) {
- td = gettyp(LCOMPLEX);
- }
- td = dup_type(td);
- td->t_typedef = true;
- return td;
- }
- break;
- /* LINTED206: (enumeration values not handled in switch) */
- case NOTSPEC:
- case USHORT:
- case UCHAR:
- case SCHAR:
- case CHAR:
- case BOOL:
- case FUNC:
- case ARRAY:
- case PTR:
- case ENUM:
- case UNION:
- case STRUCT:
- case VOID:
- case LDOUBLE:
- case FLOAT:
- case DOUBLE:
- case UQUAD:
- case QUAD:
-#ifdef INT128_SIZE
- case UINT128:
- case INT128:
-#endif
- case ULONG:
- case UINT:
- case INT:
- case FCOMPLEX:
- case DCOMPLEX:
- case LCOMPLEX:
- case COMPLEX:
- break;
+ td = dup_type(td);
+ td->t_typedef = true;
+ return td;
}
- /* Anything other is not accepted. */
-
+ /* Anything else is not accepted. */
dcs->d_invalid_type_combination = true;
return td;
}
Home |
Main Index |
Thread Index |
Old Index