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: narrow down parameter of build_name



details:   https://anonhg.NetBSD.org/src/rev/49fe1603305f
branches:  trunk
changeset: 1027710:49fe1603305f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 16 23:46:21 2021 +0000

description:
lint: narrow down parameter of build_name

Passing an arbitrary tokenizer symbol left too much freedom and
uncertainty to the caller, and 0 was a magic number in this context.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y    |  10 +++++-----
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/init.c     |   6 +++---
 usr.bin/xlint/lint1/tree.c     |  13 ++++++-------
 4 files changed, 16 insertions(+), 17 deletions(-)

diffs (140 lines):

diff -r a350c6b605f9 -r 49fe1603305f usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Thu Dec 16 22:24:10 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Thu Dec 16 23:46:21 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.374 2021/12/15 15:20:51 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.375 2021/12/16 23:46:21 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.374 2021/12/15 15:20:51 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.375 2021/12/16 23:46:21 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -432,7 +432,7 @@
                        yychar = yylex();
                sys_next = in_system_header;
                in_system_header = sys_name;
-               $$ = build_name(getsym($1), yychar);
+               $$ = build_name(getsym($1), yychar == T_LPAREN);
                in_system_header = sys_next;
          }
        | T_CON {
@@ -513,7 +513,7 @@
                if (!Sflag)
                         /* compound literals are a C9X/GCC extension */
                         gnuism(319);
-               $$ = build_name(*current_initsym(), 0);
+               $$ = build_name(*current_initsym(), false);
                end_initialization();
          }
        | T_LPAREN compound_statement_lbrace gcc_statement_expr_list {
@@ -525,7 +525,7 @@
                /* ({ }) is a GCC extension */
                gnuism(320);
          } compound_statement_rbrace T_RPAREN {
-               $$ = build_name(*current_initsym(), 0);
+               $$ = build_name(*current_initsym(), false);
                end_initialization();
          }
        ;
diff -r a350c6b605f9 -r 49fe1603305f usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Thu Dec 16 22:24:10 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Thu Dec 16 23:46:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.141 2021/12/15 00:44:05 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.142 2021/12/16 23:46:21 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -235,7 +235,7 @@
 extern type_t  *expr_derive_type(type_t *, tspec_t);
 extern bool    is_compiler_builtin(const char *);
 extern tnode_t *build_constant(type_t *, val_t *);
-extern tnode_t *build_name(sym_t *, int);
+extern tnode_t *build_name(sym_t *, bool);
 extern tnode_t *build_string(strg_t *);
 extern tnode_t *build_generic_selection(const tnode_t *,
                    struct generic_association *);
diff -r a350c6b605f9 -r 49fe1603305f usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Thu Dec 16 22:24:10 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Thu Dec 16 23:46:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.210 2021/11/16 21:01:05 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.211 2021/12/16 23:46:21 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.210 2021/11/16 21:01:05 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.211 2021/12/16 23:46:21 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -829,7 +829,7 @@
 
        debug_step("handing over to INIT");
 
-       ln = build_name(in->in_sym, 0);
+       ln = build_name(in->in_sym, false);
        ln->tn_type = expr_unqualified_type(ln->tn_type);
 
        tn = build_binary(ln, INIT, false /* XXX */, rn);
diff -r a350c6b605f9 -r 49fe1603305f usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Dec 16 22:24:10 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Dec 16 23:46:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.398 2021/12/15 00:44:05 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.399 2021/12/16 23:46:21 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.398 2021/12/15 00:44:05 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.399 2021/12/16 23:46:21 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -275,18 +275,17 @@
  * follow_token is the token which follows the name.
  */
 tnode_t *
-build_name(sym_t *sym, int follow_token)
+build_name(sym_t *sym, bool is_funcname)
 {
        tnode_t *n;
 
        if (sym->s_scl == NOSCL) {
                sym->s_scl = EXTERN;
                sym->s_def = DECL;
-               if (follow_token == T_LPAREN) {
+               if (is_funcname)
                        build_name_call(sym);
-               } else {
+               else
                        fallback_symbol(sym);
-               }
        }
 
        lint_assert(sym->s_kind == FVFT || sym->s_kind == FMEMBER);
@@ -723,7 +722,7 @@
                ln = cconv(ln);
        }
        msym = struct_or_union_member(ln, op, getsym(member));
-       return build_binary(ln, op, sys, build_name(msym, 0));
+       return build_binary(ln, op, sys, build_name(msym, false));
 }
 
 /*



Home | Main Index | Thread Index | Old Index