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: merge duplicate code for generatin...
details: https://anonhg.NetBSD.org/src/rev/0ab6ff6d2ba9
branches: trunk
changeset: 984918:0ab6ff6d2ba9
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 31 11:03:04 2021 +0000
description:
lint: merge duplicate code for generating unqualified type
This is a preparation for fixing the wrong warnings in msg_115.c.
No functional change.
diffstat:
usr.bin/xlint/lint1/decl.c | 25 +++++++++++++++++++++++--
usr.bin/xlint/lint1/externs1.h | 3 ++-
usr.bin/xlint/lint1/func.c | 7 +++----
usr.bin/xlint/lint1/init.c | 10 ++++------
usr.bin/xlint/lint1/lint1.h | 4 +++-
usr.bin/xlint/lint1/tree.c | 7 +++----
6 files changed, 38 insertions(+), 18 deletions(-)
diffs (182 lines):
diff -r 360eeea9f878 -r 0ab6ff6d2ba9 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Jul 31 10:12:04 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Jul 31 11:03:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.210 2021/07/25 22:14:36 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.211 2021/07/31 11:03:04 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.210 2021/07/25 22:14:36 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.211 2021/07/31 11:03:04 rillig Exp $");
#endif
#include <sys/param.h>
@@ -187,6 +187,27 @@
}
/*
+ * Return the unqualified version of the type. The returned type is freed at
+ * the end of the current expression.
+ *
+ * See C99 6.2.5p25.
+ */
+type_t *
+expr_unqualified_type(const type_t *tp)
+{
+ type_t *ntp;
+
+ ntp = expr_zalloc(sizeof(*ntp));
+ *ntp = *tp;
+ ntp->t_const = false;
+ ntp->t_volatile = false;
+
+ /* TODO: deep-copy struct/union members; see msg_115.c */
+
+ return ntp;
+}
+
+/*
* Returns whether the argument is void or an incomplete array,
* struct, union or enum type.
*/
diff -r 360eeea9f878 -r 0ab6ff6d2ba9 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sat Jul 31 10:12:04 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sat Jul 31 11:03:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.121 2021/07/25 22:14:36 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.122 2021/07/31 11:03:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -145,6 +145,7 @@
extern type_t *gettyp(tspec_t);
extern type_t *dup_type(const type_t *);
extern type_t *expr_dup_type(const type_t *);
+extern type_t *expr_unqualified_type(const type_t *);
extern bool is_incomplete(const type_t *);
extern void setcomplete(type_t *, bool);
extern void add_storage_class(scl_t);
diff -r 360eeea9f878 -r 0ab6ff6d2ba9 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sat Jul 31 10:12:04 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Sat Jul 31 11:03:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.115 2021/07/23 17:06:37 rillig Exp $ */
+/* $NetBSD: func.c,v 1.116 2021/07/31 11:03:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.115 2021/07/23 17:06:37 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.116 2021/07/31 11:03:04 rillig Exp $");
#endif
#include <stdlib.h>
@@ -1091,8 +1091,7 @@
/* Create a temporary node for the left side */
ln = expr_zalloc(sizeof(*ln));
ln->tn_op = NAME;
- ln->tn_type = expr_dup_type(funcsym->s_type->t_subt);
- ln->tn_type->t_const = false;
+ ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt);
ln->tn_lvalue = true;
ln->tn_sym = funcsym; /* better than nothing */
diff -r 360eeea9f878 -r 0ab6ff6d2ba9 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sat Jul 31 10:12:04 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sat Jul 31 11:03:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.203 2021/07/20 19:44:36 rillig Exp $ */
+/* $NetBSD: init.c,v 1.204 2021/07/31 11:03:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.203 2021/07/20 19:44:36 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.204 2021/07/31 11:03:04 rillig Exp $");
#endif
#include <stdlib.h>
@@ -400,8 +400,7 @@
tspec_t lt, rt;
struct memory_block *tmem;
- ltp = expr_dup_type(tp);
- ltp->t_const = false;
+ ltp = expr_unqualified_type(tp);
/* Create a temporary node for the left side. */
ln = expr_zalloc(sizeof(*ln));
@@ -900,8 +899,7 @@
debug_step0("handing over to ASSIGN");
ln = build_name(in->in_sym, 0);
- ln->tn_type = expr_dup_type(ln->tn_type);
- ln->tn_type->t_const = false;
+ ln->tn_type = expr_unqualified_type(ln->tn_type);
tn = build_binary(ln, ASSIGN, rn);
expr(tn, false, false, false, false);
diff -r 360eeea9f878 -r 0ab6ff6d2ba9 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Sat Jul 31 10:12:04 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Sat Jul 31 11:03:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.118 2021/07/23 17:06:37 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.119 2021/07/31 11:03:04 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -192,6 +192,7 @@
};
#define t_dim t_u._t_dim
+/* TODO: rename t_str to t_sou, to avoid confusing it with strings. */
#define t_str t_u._t_str
#define t_enum t_u._t_enum
#define t_args t_u._t_args
@@ -264,6 +265,7 @@
type_t *s_type;
val_t s_value; /* value (if enum or bool constant) */
union {
+ /* XXX: what is the difference to s_type->t_str? */
struct_or_union *_s_st;
enumeration *_s_et;
tspec_t _s_tsp; /* type (only for keywords) */
diff -r 360eeea9f878 -r 0ab6ff6d2ba9 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Jul 31 10:12:04 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Jul 31 11:03:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.319 2021/07/25 10:39:10 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.320 2021/07/31 11:03:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.319 2021/07/25 10:39:10 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.320 2021/07/31 11:03:04 rillig Exp $");
#endif
#include <float.h>
@@ -3611,8 +3611,7 @@
bool dowarn;
ln = xcalloc(1, sizeof(*ln));
- ln->tn_type = expr_dup_type(tp);
- ln->tn_type->t_const = false;
+ ln->tn_type = expr_unqualified_type(tp);
ln->tn_lvalue = true;
if (typeok(FARG, n, ln, tn)) {
if (!eqtype(tp, tn->tn_type,
Home |
Main Index |
Thread Index |
Old Index