Thu Jul 15 23:54:22 2021 UTC ()
lint: reduce verboseness of merge_signedness

No functional change.


(rillig)
diff -r1.206 -r1.207 src/usr.bin/xlint/lint1/decl.c

cvs diff -r1.206 -r1.207 src/usr.bin/xlint/lint1/decl.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/decl.c 2021/07/15 23:47:00 1.206
+++ src/usr.bin/xlint/lint1/decl.c 2021/07/15 23:54:22 1.207
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.206 2021/07/15 23:47:00 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.207 2021/07/15 23:54:22 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: decl.c,v 1.206 2021/07/15 23:47:00 rillig Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.207 2021/07/15 23:54:22 rillig Exp $");
42#endif 42#endif
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <limits.h> 45#include <limits.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50 50
51const char *unnamed = "<unnamed>"; 51const char *unnamed = "<unnamed>";
52 52
53/* shared type structures for arithmetic types and void */ 53/* shared type structures for arithmetic types and void */
54static type_t *typetab; 54static type_t *typetab;
@@ -376,40 +376,36 @@ add_type(type_t *tp) @@ -376,40 +376,36 @@ add_type(type_t *tp)
376 */ 376 */
377 if (dcs->d_abstract_type != NOTSPEC) 377 if (dcs->d_abstract_type != NOTSPEC)
378 /* more than one, print error in end_type() */ 378 /* more than one, print error in end_type() */
379 dcs->d_terr = true; 379 dcs->d_terr = true;
380 dcs->d_abstract_type = t; 380 dcs->d_abstract_type = t;
381 } 381 }
382} 382}
383 383
384/* Merge the signedness into the abstract type. */ 384/* Merge the signedness into the abstract type. */
385static tspec_t 385static tspec_t
386merge_signedness(tspec_t t, tspec_t s) 386merge_signedness(tspec_t t, tspec_t s)
387{ 387{
388 388
389 if (s != SIGNED && s != UNSIGN) 389 if (s == SIGNED)
 390 return t == CHAR ? SCHAR : t;
 391 if (s != UNSIGN)
390 return t; 392 return t;
391 393 return t == CHAR ? UCHAR
392 if (t == CHAR) 394 : t == SHORT ? USHORT
393 return s == SIGNED ? SCHAR : UCHAR; 395 : t == INT ? UINT
394 if (t == SHORT) 396 : t == LONG ? ULONG
395 return s == SIGNED ? SHORT : USHORT; 397 : t == QUAD ? UQUAD
396 if (t == INT) 398 : t;
397 return s == SIGNED ? INT : UINT; 
398 if (t == LONG) 
399 return s == SIGNED ? LONG : ULONG; 
400 if (t == QUAD) 
401 return s == SIGNED ? QUAD : UQUAD; 
402 return t; 
403} 399}
404 400
405/* 401/*
406 * called if a list of declaration specifiers contains a typedef name 402 * called if a list of declaration specifiers contains a typedef name
407 * and other specifiers (except struct, union, enum, typedef name) 403 * and other specifiers (except struct, union, enum, typedef name)
408 */ 404 */
409static type_t * 405static type_t *
410tdeferr(type_t *td, tspec_t t) 406tdeferr(type_t *td, tspec_t t)
411{ 407{
412 tspec_t t2; 408 tspec_t t2;
413 409
414 t2 = td->t_tspec; 410 t2 = td->t_tspec;
415 411