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: extract build_member_access from t...



details:   https://anonhg.NetBSD.org/src/rev/3f281b55576c
branches:  trunk
changeset: 1022369:3f281b55576c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jul 14 17:07:24 2021 +0000

description:
lint: extract build_member_access from the grammar

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y    |  23 +++--------------------
 usr.bin/xlint/lint1/externs1.h |   3 ++-
 usr.bin/xlint/lint1/tree.c     |  20 ++++++++++++++++++--
 3 files changed, 23 insertions(+), 23 deletions(-)

diffs (103 lines):

diff -r b57eb4cc0505 -r 3f281b55576c usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Wed Jul 14 16:59:39 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Wed Jul 14 17:07:24 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.322 2021/07/14 16:59:39 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.323 2021/07/14 17:07:24 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.322 2021/07/14 16:59:39 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.323 2021/07/14 17:07:24 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -478,24 +478,7 @@
                $$ = new_function_call_node($1, $3);
          }
        | postfix_expression point_or_arrow T_NAME {
-               if ($1 != NULL) {
-                       sym_t   *msym;
-                       /*
-                        * XXX struct_or_union_member should be integrated
-                        * in build()
-                        */
-                       if ($2 == ARROW) {
-                               /*
-                                * must do this before struct_or_union_member
-                                * is called
-                                */
-                               $1 = cconv($1);
-                       }
-                       msym = struct_or_union_member($1, $2, getsym($3));
-                       $$ = build($2, $1, new_name_node(msym, 0));
-               } else {
-                       $$ = NULL;
-               }
+               $$ = build_member_access($1, $2, $3);
          }
        | postfix_expression T_INCDEC {
                $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
diff -r b57eb4cc0505 -r 3f281b55576c usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Wed Jul 14 16:59:39 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Wed Jul 14 17:07:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.116 2021/07/10 17:35:54 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.117 2021/07/14 17:07:24 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -212,6 +212,7 @@
                    struct generic_association *);
 
 extern tnode_t *build(op_t, tnode_t *, tnode_t *);
+extern tnode_t *build_member_access(tnode_t *, op_t, sbuf_t *);
 extern tnode_t *cconv(tnode_t *);
 extern bool    is_typeok_bool_operand(const tnode_t *);
 extern bool    typeok(op_t, int, const tnode_t *, const tnode_t *);
diff -r b57eb4cc0505 -r 3f281b55576c usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Wed Jul 14 16:59:39 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Wed Jul 14 17:07:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.313 2021/07/06 04:44:20 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.314 2021/07/14 17:07:24 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.313 2021/07/06 04:44:20 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.314 2021/07/14 17:07:24 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -687,6 +687,22 @@
        return ntn;
 }
 
+tnode_t *
+build_member_access(tnode_t *ln, op_t op, sbuf_t *member)
+{
+       sym_t   *msym;
+
+       if (ln == NULL)
+               return NULL;
+
+       if (op == ARROW) {
+               /* must do this before struct_or_union_member is called */
+               ln = cconv(ln);
+       }
+       msym = struct_or_union_member(ln, op, getsym(member));
+       return build(op, ln, new_name_node(msym, 0));
+}
+
 /*
  * Perform class conversions.
  *



Home | Main Index | Thread Index | Old Index