Sat Jul 29 11:03:19 2023 UTC ()
lint: eliminate redundant code

No functional change.


(rillig)
diff -r1.366 -r1.367 src/usr.bin/xlint/lint1/decl.c

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

--- src/usr.bin/xlint/lint1/decl.c 2023/07/29 07:49:14 1.366
+++ src/usr.bin/xlint/lint1/decl.c 2023/07/29 11:03:18 1.367
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.366 2023/07/29 07:49:14 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.367 2023/07/29 11:03:18 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) 40#if defined(__RCSID)
41__RCSID("$NetBSD: decl.c,v 1.366 2023/07/29 07:49:14 rillig Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.367 2023/07/29 11:03:18 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[NTSPEC]; 54static type_t typetab[NTSPEC];
@@ -254,46 +254,47 @@ typedef_error(type_t *td, tspec_t t) @@ -254,46 +254,47 @@ typedef_error(type_t *td, tspec_t t)
254 } 254 }
255 255
256 if (t == SHORT && (t2 == INT || t2 == UINT)) { 256 if (t == SHORT && (t2 == INT || t2 == UINT)) {
257 /* modifying typedef with '%s'; only qualifiers allowed */ 257 /* modifying typedef with '%s'; only qualifiers allowed */
258 warning(5, "short"); 258 warning(5, "short");
259 td = block_dup_type(gettyp(t2 == INT ? SHORT : USHORT)); 259 td = block_dup_type(gettyp(t2 == INT ? SHORT : USHORT));
260 td->t_typedef = true; 260 td->t_typedef = true;
261 return td; 261 return td;
262 } 262 }
263 263
264 if (t != LONG) 264 if (t != LONG)
265 goto invalid; 265 goto invalid;
266 266
 267 tspec_t lt;
267 if (t2 == INT) 268 if (t2 == INT)
268 td = gettyp(LONG); 269 lt = LONG;
269 else if (t2 == UINT) 270 else if (t2 == UINT)
270 td = gettyp(ULONG); 271 lt = ULONG;
271 else if (t2 == LONG) 272 else if (t2 == LONG)
272 td = gettyp(LLONG); 273 lt = LLONG;
273 else if (t2 == ULONG) 274 else if (t2 == ULONG)
274 td = gettyp(ULLONG); 275 lt = ULLONG;
275 else if (t2 == FLOAT) 276 else if (t2 == FLOAT)
276 td = gettyp(DOUBLE); 277 lt = DOUBLE;
277 else if (t2 == DOUBLE) 278 else if (t2 == DOUBLE)
278 td = gettyp(LDOUBLE); 279 lt = LDOUBLE;
279 else if (t2 == DCOMPLEX) 280 else if (t2 == DCOMPLEX)
280 td = gettyp(LCOMPLEX); 281 lt = LCOMPLEX;
281 else 282 else
282 goto invalid; 283 goto invalid;
283 284
284 /* modifying typedef with '%s'; only qualifiers allowed */ 285 /* modifying typedef with '%s'; only qualifiers allowed */
285 warning(5, "long"); 286 warning(5, "long");
286 td = block_dup_type(td); 287 td = block_dup_type(gettyp(lt));
287 td->t_typedef = true; 288 td->t_typedef = true;
288 return td; 289 return td;
289 290
290invalid: 291invalid:
291 /* Anything else is not accepted. */ 292 /* Anything else is not accepted. */
292 dcs->d_invalid_type_combination = true; 293 dcs->d_invalid_type_combination = true;
293 return td; 294 return td;
294} 295}
295 296
296/* 297/*
297 * Remember the type, modifier or typedef name returned by the parser in the 298 * Remember the type, modifier or typedef name returned by the parser in the
298 * top element of the declaration stack. This information is used in 299 * top element of the declaration stack. This information is used in
299 * dcs_end_type to build the type used for all declarators in this declaration. 300 * dcs_end_type to build the type used for all declarators in this declaration.