Module Name: src
Committed By: rillig
Date: Wed Jul 12 19:34:01 UTC 2023
Modified Files:
src/usr.bin/xlint/lint1: debug.c tree.c
Log Message:
lint: clean up handling of __real__ and __imag__
These two operatos are not binary, therefore they don't need a right
operand. The questionable operands were a copy-and-paste mistake, as
the code was taken from the ++ and -- operands (tree.c 1.46 from
2008-04-25). The ++ and -- operands aren't binary either, but since
lint represents address calculations in their premultiplied form, the
expression ptr++ contains a hidden right operand specifying the number
of bytes by which to increment the pointer.
Creating an integer-constant-expression node with type 'long double'
didn't make sense either. Luckily, these expressions are only built but
not analyzed any further.
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.560 -r1.561 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.51 src/usr.bin/xlint/lint1/debug.c:1.52
--- src/usr.bin/xlint/lint1/debug.c:1.51 Wed Jul 12 18:26:04 2023
+++ src/usr.bin/xlint/lint1/debug.c Wed Jul 12 19:34:01 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.51 2023/07/12 18:26:04 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.52 2023/07/12 19:34:01 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.51 2023/07/12 18:26:04 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.52 2023/07/12 19:34:01 rillig Exp $");
#endif
#include <stdlib.h>
@@ -227,7 +227,7 @@ debug_node(const tnode_t *tn) // NOLINT(
debug_node(tn->tn_left);
if (op != INCBEF && op != INCAFT
&& op != DECBEF && op != DECAFT
- && op != CALL && op != PUSH)
+ && op != CALL && op != ICALL && op != PUSH)
lint_assert(is_binary(tn) == (tn->tn_right != NULL));
if (tn->tn_right != NULL)
debug_node(tn->tn_right);
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.560 src/usr.bin/xlint/lint1/tree.c:1.561
--- src/usr.bin/xlint/lint1/tree.c:1.560 Mon Jul 10 19:47:12 2023
+++ src/usr.bin/xlint/lint1/tree.c Wed Jul 12 19:34:01 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.560 2023/07/10 19:47:12 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.561 2023/07/12 19:34:01 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.560 2023/07/10 19:47:12 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.561 2023/07/12 19:34:01 rillig Exp $");
#endif
#include <float.h>
@@ -1391,19 +1391,16 @@ build_real_imag(op_t op, bool sys, tnode
mark_as_set(ln->tn_sym);
}
- tnode_t *cn;
+ tspec_t t;
switch (ln->tn_type->t_tspec) {
case LCOMPLEX:
- /* XXX: integer and LDOUBLE don't match. */
- cn = build_integer_constant(LDOUBLE, (int64_t)1);
+ t = LDOUBLE;
break;
case DCOMPLEX:
- /* XXX: integer and DOUBLE don't match. */
- cn = build_integer_constant(DOUBLE, (int64_t)1);
+ t = DOUBLE;
break;
case FCOMPLEX:
- /* XXX: integer and FLOAT don't match. */
- cn = build_integer_constant(FLOAT, (int64_t)1);
+ t = FLOAT;
break;
default:
/* '__%s__' is illegal for type '%s' */
@@ -1412,7 +1409,7 @@ build_real_imag(op_t op, bool sys, tnode
return NULL;
}
- tnode_t *ntn = new_tnode(op, sys, cn->tn_type, ln, cn);
+ tnode_t *ntn = new_tnode(op, sys, gettyp(t), ln, NULL);
ntn->tn_lvalue = true;
return ntn;
}