lint: prepare renaming of 'struct type' It's confusing to have the same struct tag in both lint1 and lint2, with mostly the same members, but also some differences. Before actually changing this, I reviewed all occurrences of the word 'type' in the code. No functional change.diff -r1.171 -r1.172 src/usr.bin/xlint/lint1/decl.c
(rillig)
--- src/usr.bin/xlint/lint1/decl.c 2021/04/09 20:12:00 1.171
+++ src/usr.bin/xlint/lint1/decl.c 2021/04/10 18:06:53 1.172
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl.c,v 1.171 2021/04/09 20:12:00 rillig Exp $ */ | 1 | /* $NetBSD: decl.c,v 1.172 2021/04/10 18:06:53 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.171 2021/04/09 20:12:00 rillig Exp $"); | 41 | __RCSID("$NetBSD: decl.c,v 1.172 2021/04/10 18:06:53 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 | |||
51 | const char *unnamed = "<unnamed>"; | 51 | const char *unnamed = "<unnamed>"; | |
52 | 52 | |||
53 | /* shared type structures for arithmetic types and void */ | 53 | /* shared type structures for arithmetic types and void */ | |
54 | static type_t *typetab; | 54 | static type_t *typetab; | |
@@ -131,26 +131,27 @@ initdecl(void) | @@ -131,26 +131,27 @@ initdecl(void) | |||
131 | } | 131 | } | |
132 | 132 | |||
133 | /* | 133 | /* | |
134 | * Returns a shared type structure for arithmetic types and void. | 134 | * Returns a shared type structure for arithmetic types and void. | |
135 | * | 135 | * | |
136 | * It's important to duplicate this structure (using dup_type() or | 136 | * It's important to duplicate this structure (using dup_type() or | |
137 | * expr_dup_type()) if it is to be modified (adding qualifiers or anything | 137 | * expr_dup_type()) if it is to be modified (adding qualifiers or anything | |
138 | * else). | 138 | * else). | |
139 | */ | 139 | */ | |
140 | type_t * | 140 | type_t * | |
141 | gettyp(tspec_t t) | 141 | gettyp(tspec_t t) | |
142 | { | 142 | { | |
143 | 143 | |||
144 | /* TODO: make the return type 'const' */ | |||
144 | return &typetab[t]; | 145 | return &typetab[t]; | |
145 | } | 146 | } | |
146 | 147 | |||
147 | type_t * | 148 | type_t * | |
148 | dup_type(const type_t *tp) | 149 | dup_type(const type_t *tp) | |
149 | { | 150 | { | |
150 | type_t *ntp; | 151 | type_t *ntp; | |
151 | 152 | |||
152 | ntp = getblk(sizeof(*ntp)); | 153 | ntp = getblk(sizeof(*ntp)); | |
153 | *ntp = *tp; | 154 | *ntp = *tp; | |
154 | return ntp; | 155 | return ntp; | |
155 | } | 156 | } | |
156 | 157 |
--- src/usr.bin/xlint/lint1/func.c 2021/04/02 15:06:35 1.102
+++ src/usr.bin/xlint/lint1/func.c 2021/04/10 18:06:53 1.103
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: func.c,v 1.102 2021/04/02 15:06:35 rillig Exp $ */ | 1 | /* $NetBSD: func.c,v 1.103 2021/04/10 18:06:53 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * All Rights Reserved. | 5 | * All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: func.c,v 1.102 2021/04/02 15:06:35 rillig Exp $"); | 40 | __RCSID("$NetBSD: func.c,v 1.103 2021/04/10 18:06:53 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | 45 | |||
46 | #include "lint1.h" | 46 | #include "lint1.h" | |
47 | #include "cgram.h" | 47 | #include "cgram.h" | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * Contains a pointer to the symbol table entry of the current function | 50 | * Contains a pointer to the symbol table entry of the current function | |
51 | * definition. | 51 | * definition. | |
52 | */ | 52 | */ | |
53 | sym_t *funcsym; | 53 | sym_t *funcsym; | |
@@ -509,30 +509,27 @@ check_case_label(tnode_t *tn, cstk_t *ci | @@ -509,30 +509,27 @@ check_case_label(tnode_t *tn, cstk_t *ci | |||
509 | for (cl = ci->c_case_labels; cl != NULL; cl = cl->cl_next) { | 509 | for (cl = ci->c_case_labels; cl != NULL; cl = cl->cl_next) { | |
510 | if (cl->cl_val.v_quad == nv.v_quad) | 510 | if (cl->cl_val.v_quad == nv.v_quad) | |
511 | break; | 511 | break; | |
512 | } | 512 | } | |
513 | if (cl != NULL && is_uinteger(nv.v_tspec)) { | 513 | if (cl != NULL && is_uinteger(nv.v_tspec)) { | |
514 | /* duplicate case in switch: %lu */ | 514 | /* duplicate case in switch: %lu */ | |
515 | error(200, (u_long)nv.v_quad); | 515 | error(200, (u_long)nv.v_quad); | |
516 | } else if (cl != NULL) { | 516 | } else if (cl != NULL) { | |
517 | /* duplicate case in switch: %ld */ | 517 | /* duplicate case in switch: %ld */ | |
518 | error(199, (long)nv.v_quad); | 518 | error(199, (long)nv.v_quad); | |
519 | } else { | 519 | } else { | |
520 | check_getopt_case_label(nv.v_quad); | 520 | check_getopt_case_label(nv.v_quad); | |
521 | 521 | |||
522 | /* | 522 | /* append the value to the list of case values */ | |
523 | * append the value to the list of | |||
524 | * case values | |||
525 | */ | |||
526 | cl = xcalloc(1, sizeof(*cl)); | 523 | cl = xcalloc(1, sizeof(*cl)); | |
527 | cl->cl_val = nv; | 524 | cl->cl_val = nv; | |
528 | cl->cl_next = ci->c_case_labels; | 525 | cl->cl_next = ci->c_case_labels; | |
529 | ci->c_case_labels = cl; | 526 | ci->c_case_labels = cl; | |
530 | } | 527 | } | |
531 | } | 528 | } | |
532 | 529 | |||
533 | void | 530 | void | |
534 | case_label(tnode_t *tn) | 531 | case_label(tnode_t *tn) | |
535 | { | 532 | { | |
536 | cstk_t *ci; | 533 | cstk_t *ci; | |
537 | 534 | |||
538 | /* find the innermost switch statement */ | 535 | /* find the innermost switch statement */ |
--- src/usr.bin/xlint/lint1/lint1.h 2021/04/02 22:05:43 1.92
+++ src/usr.bin/xlint/lint1/lint1.h 2021/04/10 18:06:53 1.93
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint1.h,v 1.92 2021/04/02 22:05:43 rillig Exp $ */ | 1 | /* $NetBSD: lint1.h,v 1.93 2021/04/10 18:06:53 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 | |
@@ -135,28 +135,28 @@ typedef struct { | @@ -135,28 +135,28 @@ typedef struct { | |||
135 | } struct_or_union; | 135 | } struct_or_union; | |
136 | 136 | |||
137 | /* | 137 | /* | |
138 | * same as above for enums | 138 | * same as above for enums | |
139 | */ | 139 | */ | |
140 | typedef struct { | 140 | typedef struct { | |
141 | bool en_incomplete : 1; | 141 | bool en_incomplete : 1; | |
142 | struct sym *en_first_enumerator; | 142 | struct sym *en_first_enumerator; | |
143 | struct sym *en_tag; | 143 | struct sym *en_tag; | |
144 | struct sym *en_first_typedef; | 144 | struct sym *en_first_typedef; | |
145 | } enumeration; | 145 | } enumeration; | |
146 | 146 | |||
147 | /* | 147 | /* | |
148 | * Types are represented by concatenation of structures of type type_t | 148 | * The type of an expression or object. Complex types are formed via t_subt | |
149 | * via t_subt. | 149 | * (for arrays, pointers and functions), as well as t_str. | |
150 | */ | 150 | */ | |
151 | struct type { | 151 | struct type { | |
152 | tspec_t t_tspec; /* type specifier */ | 152 | tspec_t t_tspec; /* type specifier */ | |
153 | bool t_incomplete_array : 1; | 153 | bool t_incomplete_array : 1; | |
154 | bool t_const : 1; /* const modifier */ | 154 | bool t_const : 1; /* const modifier */ | |
155 | bool t_volatile : 1; /* volatile modifier */ | 155 | bool t_volatile : 1; /* volatile modifier */ | |
156 | bool t_proto : 1; /* function prototype (t_args valid) */ | 156 | bool t_proto : 1; /* function prototype (t_args valid) */ | |
157 | bool t_vararg : 1; /* prototype with '...' */ | 157 | bool t_vararg : 1; /* prototype with '...' */ | |
158 | bool t_typedef : 1; /* type defined with typedef */ | 158 | bool t_typedef : 1; /* type defined with typedef */ | |
159 | bool t_bitfield : 1; | 159 | bool t_bitfield : 1; | |
160 | bool t_is_enum : 1; /* type is (or was) enum (t_enum valid) */ | 160 | bool t_is_enum : 1; /* type is (or was) enum (t_enum valid) */ | |
161 | bool t_packed : 1; | 161 | bool t_packed : 1; | |
162 | union { | 162 | union { | |
@@ -361,27 +361,28 @@ typedef struct dinfo { | @@ -361,27 +361,28 @@ typedef struct dinfo { | |||
361 | 361 | |||
362 | /* | 362 | /* | |
363 | * Used to collect information about pointers and qualifiers in | 363 | * Used to collect information about pointers and qualifiers in | |
364 | * declarators. | 364 | * declarators. | |
365 | */ | 365 | */ | |
366 | typedef struct pqinf { | 366 | typedef struct pqinf { | |
367 | int p_pcnt; /* number of asterisks */ | 367 | int p_pcnt; /* number of asterisks */ | |
368 | bool p_const : 1; | 368 | bool p_const : 1; | |
369 | bool p_volatile : 1; | 369 | bool p_volatile : 1; | |
370 | struct pqinf *p_next; | 370 | struct pqinf *p_next; | |
371 | } pqinf_t; | 371 | } pqinf_t; | |
372 | 372 | |||
373 | /* | 373 | /* | |
374 | * Case values are stored in a list of type case_label_t. | 374 | * The values of the 'case' labels, linked via cl_next in reverse order of | |
375 | * appearance in the code, that is from bottom to top. | |||
375 | */ | 376 | */ | |
376 | typedef struct case_label { | 377 | typedef struct case_label { | |
377 | val_t cl_val; | 378 | val_t cl_val; | |
378 | struct case_label *cl_next; | 379 | struct case_label *cl_next; | |
379 | } case_label_t; | 380 | } case_label_t; | |
380 | 381 | |||
381 | typedef enum { | 382 | typedef enum { | |
382 | CS_DO_WHILE, | 383 | CS_DO_WHILE, | |
383 | CS_FOR, | 384 | CS_FOR, | |
384 | CS_FUNCTION_BODY, | 385 | CS_FUNCTION_BODY, | |
385 | CS_IF, | 386 | CS_IF, | |
386 | CS_SWITCH, | 387 | CS_SWITCH, | |
387 | CS_WHILE | 388 | CS_WHILE |
--- src/usr.bin/xlint/lint1/tree.c 2021/04/09 21:42:12 1.275
+++ src/usr.bin/xlint/lint1/tree.c 2021/04/10 18:06:53 1.276
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tree.c,v 1.275 2021/04/09 21:42:12 rillig Exp $ */ | 1 | /* $NetBSD: tree.c,v 1.276 2021/04/10 18:06:53 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * All Rights Reserved. | 5 | * All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: tree.c,v 1.275 2021/04/09 21:42:12 rillig Exp $"); | 40 | __RCSID("$NetBSD: tree.c,v 1.276 2021/04/10 18:06:53 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <float.h> | 43 | #include <float.h> | |
44 | #include <limits.h> | 44 | #include <limits.h> | |
45 | #include <math.h> | 45 | #include <math.h> | |
46 | #include <signal.h> | 46 | #include <signal.h> | |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> | |
48 | #include <string.h> | 48 | #include <string.h> | |
49 | 49 | |||
50 | #include "lint1.h" | 50 | #include "lint1.h" | |
51 | #include "cgram.h" | 51 | #include "cgram.h" | |
52 | 52 | |||
53 | static tnode_t *expr_new_integer_constant(tspec_t, int64_t); | 53 | static tnode_t *expr_new_integer_constant(tspec_t, int64_t); | |
@@ -2101,26 +2101,30 @@ check_pointer_conversion(tnode_t *tn, ty | @@ -2101,26 +2101,30 @@ check_pointer_conversion(tnode_t *tn, ty | |||
2101 | * nv new constant | 2101 | * nv new constant | |
2102 | * v old constant | 2102 | * v old constant | |
2103 | */ | 2103 | */ | |
2104 | void | 2104 | void | |
2105 | convert_constant(op_t op, int arg, const type_t *tp, val_t *nv, val_t *v) | 2105 | convert_constant(op_t op, int arg, const type_t *tp, val_t *nv, val_t *v) | |
2106 | { | 2106 | { | |
2107 | tspec_t ot, nt; | 2107 | tspec_t ot, nt; | |
2108 | ldbl_t max = 0.0, min = 0.0; | 2108 | ldbl_t max = 0.0, min = 0.0; | |
2109 | int sz; | 2109 | int sz; | |
2110 | bool rchk; | 2110 | bool rchk; | |
2111 | int64_t xmask, xmsk1; | 2111 | int64_t xmask, xmsk1; | |
2112 | int osz, nsz; | 2112 | int osz, nsz; | |
2113 | 2113 | |||
2114 | /* | |||
2115 | * TODO: make 'v' const; the name of this function does not suggest | |||
2116 | * that it modifies 'v'. | |||
2117 | */ | |||
2114 | ot = v->v_tspec; | 2118 | ot = v->v_tspec; | |
2115 | nt = nv->v_tspec = tp->t_tspec; | 2119 | nt = nv->v_tspec = tp->t_tspec; | |
2116 | rchk = false; | 2120 | rchk = false; | |
2117 | 2121 | |||
2118 | if (nt == BOOL) { /* C99 6.3.1.2 */ | 2122 | if (nt == BOOL) { /* C99 6.3.1.2 */ | |
2119 | nv->v_ansiu = false; | 2123 | nv->v_ansiu = false; | |
2120 | nv->v_quad = is_nonzero_val(v) ? 1 : 0; | 2124 | nv->v_quad = is_nonzero_val(v) ? 1 : 0; | |
2121 | return; | 2125 | return; | |
2122 | } | 2126 | } | |
2123 | 2127 | |||
2124 | if (ot == FLOAT || ot == DOUBLE || ot == LDOUBLE) { | 2128 | if (ot == FLOAT || ot == DOUBLE || ot == LDOUBLE) { | |
2125 | switch (nt) { | 2129 | switch (nt) { | |
2126 | case CHAR: | 2130 | case CHAR: |