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: extract dcs_merge_declaration_spec...
details: https://anonhg.NetBSD.org/src/rev/2971f598b946
branches: trunk
changeset: 984675:2971f598b946
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jul 15 23:07:05 2021 +0000
description:
lint: extract dcs_merge_declaration_specifiers from end_type
No functional change.
diffstat:
tests/usr.bin/xlint/lint1/decl.c | 8 +-
usr.bin/xlint/lint1/decl.c | 137 ++++++++++++++++++++------------------
2 files changed, 77 insertions(+), 68 deletions(-)
diffs (197 lines):
diff -r 82a12fd108a0 -r 2971f598b946 tests/usr.bin/xlint/lint1/decl.c
--- a/tests/usr.bin/xlint/lint1/decl.c Thu Jul 15 22:47:17 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl.c Thu Jul 15 23:07:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.8 2021/07/15 21:56:51 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.9 2021/07/15 23:07:05 rillig Exp $ */
# 3 "decl.c"
/*
@@ -145,6 +145,9 @@
unsigned int unsigned_int;
long signed_long;
unsigned long unsigned_long;
+struct {
+ int member;
+} unnamed_struct;
/*
* Before decl.c 1.201 from 2021-07-15, lint crashed with an internal error
@@ -160,4 +163,5 @@
sizeof(const typeof(signed_int)) +
sizeof(const typeof(unsigned_int)) +
sizeof(const typeof(signed_long)) +
- sizeof(const typeof(unsigned_long));
+ sizeof(const typeof(unsigned_long)) +
+ sizeof(const typeof(unnamed_struct));
diff -r 82a12fd108a0 -r 2971f598b946 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Thu Jul 15 22:47:17 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Thu Jul 15 23:07:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.203 2021/07/15 22:47:17 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.204 2021/07/15 23:07:05 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.203 2021/07/15 22:47:17 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.204 2021/07/15 23:07:05 rillig Exp $");
#endif
#include <sys/param.h>
@@ -746,14 +746,9 @@
}
}
-/*
- * Create a type structure from the information gathered in
- * the declaration stack.
- * Complain about storage classes which are not possible in current
- * context.
- */
-void
-end_type(void)
+/* Merge the declaration specifiers from dcs into dcs->d_type. */
+static void
+dcs_merge_declaration_specifiers(void)
{
tspec_t t, s, l, c;
type_t *tp;
@@ -778,68 +773,78 @@
lint_assert(t == NOTSPEC);
lint_assert(s == NOTSPEC);
lint_assert(l == NOTSPEC);
+ return;
}
- if (tp == NULL) {
- switch (t) {
- case BOOL:
- break;
- case NOTSPEC:
- t = INT;
- /* FALLTHROUGH */
- case INT:
- if (s == NOTSPEC)
- s = SIGNED;
- break;
- case CHAR:
- if (l != NOTSPEC) {
- dcs->d_terr = true;
- l = NOTSPEC;
- }
- break;
- case FLOAT:
- if (l == LONG) {
- l = NOTSPEC;
- t = DOUBLE;
- if (!tflag)
- /* use 'double' instead of 'long ... */
- warning(6);
- }
+ switch (t) {
+ case BOOL:
+ break;
+ case NOTSPEC:
+ t = INT;
+ /* FALLTHROUGH */
+ case INT:
+ if (s == NOTSPEC)
+ s = SIGNED;
+ break;
+ case CHAR:
+ if (l != NOTSPEC) {
+ dcs->d_terr = true;
+ l = NOTSPEC;
+ }
+ break;
+ case FLOAT:
+ if (l == LONG) {
+ l = NOTSPEC;
+ t = DOUBLE;
+ if (!tflag)
+ /* use 'double' instead of 'long float' */
+ warning(6);
+ }
+ break;
+ case DOUBLE:
+ if (l != LONG)
break;
- case DOUBLE:
- if (l != LONG)
- break;
- /* FALLTHROUGH */
- case LDOUBLE:
+ /* FALLTHROUGH */
+ case LDOUBLE:
+ l = NOTSPEC;
+ t = LDOUBLE;
+ if (tflag)
+ /* 'long double' is illegal in traditional C */
+ warning(266);
+ break;
+ case DCOMPLEX:
+ if (l == LONG) {
l = NOTSPEC;
- t = LDOUBLE;
- if (tflag)
- /* 'long double' is illegal in ... */
- warning(266);
- break;
- case DCOMPLEX:
- if (l == LONG) {
- l = NOTSPEC;
- t = LCOMPLEX;
- }
- break;
- case VOID:
- case FCOMPLEX:
- case LCOMPLEX:
- break;
- default:
- if (is_integer(t))
- break;
- INTERNAL_ERROR("end_type(%s)", tspec_name(t));
+ t = LCOMPLEX;
}
- if (t != INT && t != CHAR && (s != NOTSPEC || l != NOTSPEC)) {
- dcs->d_terr = true;
- l = s = NOTSPEC;
- }
- if (l != NOTSPEC)
- t = l;
- dcs->d_type = gettyp(merge_type_specifiers(t, s));
+ break;
+ case VOID:
+ case FCOMPLEX:
+ case LCOMPLEX:
+ break;
+ default:
+ lint_assert(is_integer(t));
+ }
+ if (t != INT && t != CHAR && (s != NOTSPEC || l != NOTSPEC)) {
+ dcs->d_terr = true;
+ l = s = NOTSPEC;
}
+ if (l != NOTSPEC)
+ t = l;
+ dcs->d_type = gettyp(merge_type_specifiers(t, s));
+}
+
+/*
+ * Create a type structure from the information gathered in
+ * the declaration stack.
+ * Complain about storage classes which are not possible in current
+ * context.
+ */
+void
+end_type(void)
+{
+
+ dcs_merge_declaration_specifiers();
if (dcs->d_mscl) {
/* only one storage class allowed */
Home |
Main Index |
Thread Index |
Old Index