Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint recognize int128



details:   https://anonhg.NetBSD.org/src/rev/6f1418b9be7d
branches:  trunk
changeset: 993371:6f1418b9be7d
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Sep 07 15:16:15 2018 +0000

description:
recognize int128

diffstat:

 usr.bin/xlint/common/inittyp.c |  13 +++++++++++--
 usr.bin/xlint/common/lint.h    |   6 +++++-
 usr.bin/xlint/common/lp64.h    |   7 ++++++-
 usr.bin/xlint/common/tyname.c  |  16 ++++++++++++++--
 usr.bin/xlint/lint1/decl.c     |   8 ++++++--
 usr.bin/xlint/lint1/err.c      |   8 ++++----
 usr.bin/xlint/lint1/scan.l     |  37 ++++++++++++++++++++++++++++++++-----
 usr.bin/xlint/lint1/tree.c     |  10 ++++++----
 usr.bin/xlint/lint2/read.c     |  14 +++++++++++---
 9 files changed, 95 insertions(+), 24 deletions(-)

diffs (truncated from 349 to 300 lines):

diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/common/inittyp.c
--- a/usr.bin/xlint/common/inittyp.c    Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/common/inittyp.c    Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inittyp.c,v 1.11 2009/04/15 01:20:57 christos Exp $    */
+/*     $NetBSD: inittyp.c,v 1.12 2018/09/07 15:16:15 christos Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.11 2009/04/15 01:20:57 christos Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.12 2018/09/07 15:16:15 christos Exp $");
 #endif
 
 #include <limits.h>
@@ -104,6 +104,15 @@
                { UQUAD,    { QUAD_SIZE, 8 * CHAR_BIT,
                                      QUAD, UQUAD,
                                      1, 1, 0, 1, 1, 0, "unsigned long long" } },
+#ifdef INT128_SIZE
+               { INT128,   { INT128_SIZE, 16 * CHAR_BIT,
+                                     INT128, UINT128,
+                                     1, 0, 0, 1, 1, 0, "__int128_t" } },
+               { UINT128,  { INT128_SIZE, 16 * CHAR_BIT,
+                                     INT128, UINT128,
+                                     1, 1, 0, 1, 1, 0, "__uint128_t" } },
+#endif
+
                { FLOAT,    { FLOAT_SIZE, 4 * CHAR_BIT,
                                      FLOAT, FLOAT,
                                      0, 0, 1, 1, 1, 0, "float" } },
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/common/lint.h       Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lint.h,v 1.13 2009/04/15 01:20:57 christos Exp $       */
+/*     $NetBSD: lint.h,v 1.14 2018/09/07 15:16:15 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -64,6 +64,10 @@
        ULONG,          /* unsigned long */
        QUAD,           /* (signed) long long */
        UQUAD,          /* unsigned long long */
+#ifdef INT128_SIZE
+       INT128,         /* (signed) __int128_t */
+       UINT128,        /* __uint128_t */
+#endif
        FLOAT,          /* float */
        DOUBLE,         /* double or, with tflag, long float */
        LDOUBLE,        /* long double */
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/common/lp64.h
--- a/usr.bin/xlint/common/lp64.h       Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/common/lp64.h       Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lp64.h,v 1.4 2012/03/27 19:24:03 christos Exp $        */
+/*     $NetBSD: lp64.h,v 1.5 2018/09/07 15:16:15 christos Exp $        */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -45,6 +45,7 @@
 #define        LONG_SIZE       (8 * CHAR_BIT)
 #define        QUAD_SIZE       (8 * CHAR_BIT)
 #define        PTR_SIZE        (8 * CHAR_BIT)
+#define        INT128_SIZE     (16 * CHAR_BIT)
 
 #define        TARG_SCHAR_MAX  ((signed char) (((unsigned char) -1) >> 1))
 #define        TARG_SCHAR_MIN  ((-TARG_CHAR_MAX) - 1)
@@ -65,3 +66,7 @@
 #define        TARG_QUAD_MAX   ((int64_t) (((uint64_t) -1) >> 1))
 #define        TARG_QUAD_MIN   ((-TARG_QUAD_MAX) - 1)
 #define        TARG_UQUAD_MAX  ((uint64_t) -1)
+
+#define        TARG_INT128_MAX         ((__int128_t) (((__uint128_t) -1) >> 1))
+#define        TARG_INT128_MIN         ((-TARG_INT128_MAX) - 1)
+#define        TARG_UINT128_MAX        ((__uint128_t) -1)
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/common/tyname.c     Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.12 2016/08/19 10:18:11 christos Exp $     */
+/*     $NetBSD: tyname.c,v 1.13 2018/09/07 15:16:15 christos Exp $     */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.12 2016/08/19 10:18:11 christos Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.13 2018/09/07 15:16:15 christos Exp $");
 #endif
 
 #include <limits.h>
@@ -68,6 +68,10 @@
        case ULONG:     return "unsigned long";
        case QUAD:      return "long long";
        case UQUAD:     return "unsigned long long";
+#ifdef INT128_SIZE
+       case INT128:    return "__int128_t";
+       case UINT128:   return "__uint128_t";
+#endif
        case FLOAT:     return "float";
        case DOUBLE:    return "double";
        case LDOUBLE:   return "long double";
@@ -111,6 +115,10 @@
        case ULONG:
        case QUAD:
        case UQUAD:
+#ifdef INT128_SIZE
+       case INT128:
+       case UINT128:
+#endif
        case FLOAT:
        case DOUBLE:
        case LDOUBLE:
@@ -182,6 +190,10 @@
        case ULONG:
        case QUAD:
        case UQUAD:
+#ifdef INT128_SIZE
+       case INT128:
+       case UINT128:
+#endif
        case FLOAT:
        case DOUBLE:
        case LDOUBLE:
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.68 2017/03/06 23:04:52 christos Exp $ */
+/* $NetBSD: decl.c,v 1.69 2018/09/07 15:16:15 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.68 2017/03/06 23:04:52 christos Exp $");
+__RCSID("$NetBSD: decl.c,v 1.69 2018/09/07 15:16:15 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -446,6 +446,10 @@
        case DOUBLE:
        case UQUAD:
        case QUAD:
+#ifdef INT128_SIZE
+       case UINT128:
+       case INT128:
+#endif
        case ULONG:
        case UINT:
        case INT:
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/lint1/err.c Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.52 2018/01/15 22:14:24 christos Exp $        */
+/*     $NetBSD: err.c,v 1.53 2018/09/07 15:16:15 christos Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.52 2018/01/15 22:14:24 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.53 2018/09/07 15:16:15 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -244,7 +244,7 @@
        "incompatible pointer types (%s != %s)",                      /* 182 */
        "illegal combination of %s (%s) and %s (%s)",                 /* 183 */
        "illegal pointer combination",                                /* 184 */
-       "initialisation type mismatch",                               /* 185 */
+       "initialisation type mismatch (%s) and (%s)",                 /* 185 */
        "bit-field initialisation is illegal in traditional C",       /* 186 */
        "non-null byte ignored in string initializer",                /* 187 */
        "no automatic aggregate initialization in traditional C",     /* 188 */
@@ -270,7 +270,7 @@
        "break outside loop or switch",                               /* 208 */
        "continue outside loop",                                      /* 209 */
        "enum type mismatch in initialisation",                       /* 210 */
-       "return value type mismatch",                                 /* 211 */
+       "return value type mismatch (%s) and (%s)",                   /* 211 */
        "cannot return incomplete type",                              /* 212 */
        "void function %s cannot return value",                       /* 213 */
        "function %s expects to return value",                        /* 214 */
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Fri Sep 07 15:16:15 2018 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.82 2018/07/08 17:48:42 christos Exp $ */
+/* $NetBSD: scan.l,v 1.83 2018/09/07 15:16:15 christos 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: scan.l,v 1.82 2018/07/08 17:48:42 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.83 2018/09/07 15:16:15 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -205,6 +205,10 @@
        u_int   kw_attr : 1;    /* GCC attribute, keyword */
        u_int   kw_deco : 3;    /* name[1] __name[2] __name__[4] */
 } kwtab[] = {
+#ifdef INT128_SIZE
+       { "__int128_t", T_TYPE,         0,      INT128, 0,        0,1,0,0,1 },
+       { "__uint128_t",T_TYPE,         0,      UINT128,0,        0,1,0,0,1 },
+#endif
        { "_Bool",      T_TYPE,         0,      BOOL,   0,        0,1,0,0,1 },
        { "_Complex",   T_TYPE,         0,      COMPLEX,0,        0,1,0,0,1 },
        { "_Generic",   T_GENERIC,      0,      0,      0,        0,1,0,0,1 },
@@ -553,12 +557,20 @@
        const   char *cp;
        char    c, *eptr;
        tspec_t typ;
+       int     ansiu;
+#ifdef INT128_SIZE
+       __uint128_t uq = 0;
+       static  tspec_t contypes[2][4] = {
+               { INT,  LONG,  QUAD, INT128, },
+               { UINT, ULONG, UQUAD, UINT128, }
+       };
+#else
        uint64_t uq = 0;
-       int     ansiu;
        static  tspec_t contypes[2][3] = {
-               { INT,  LONG,  QUAD },
-               { UINT, ULONG, UQUAD }
+               { INT,  LONG,  QUAD, },
+               { UINT, ULONG, UQUAD, }
        };
+#endif
 
        cp = yytext;
        len = yyleng;
@@ -675,6 +687,21 @@
                        warning(252);
                }
                break;
+#ifdef INT128_SIZE
+       case INT128:
+               if (uq > TARG_INT128_MAX && !tflag) {
+                       typ = UINT128;
+                       if (!sflag)
+                               ansiu = 1;
+               }
+               break;
+       case UINT128:
+               if (uq > TARG_UINT128_MAX) {
+                       /* integer constant out of range */
+                       warning(252);
+               }
+               break;
+#endif
                /* LINTED206: (enumeration values not handled in switch) */
        case STRUCT:
        case VOID:
diff -r 2cbb84615d9f -r 6f1418b9be7d usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Fri Sep 07 14:47:15 2018 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Fri Sep 07 15:16:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.85 2018/06/29 20:18:05 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.86 2018/09/07 15:16:15 christos 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.85 2018/06/29 20:18:05 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.86 2018/09/07 15:16:15 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1298,11 +1298,13 @@
        switch (op) {
        case INIT:
                /* initialisation type mismatch */
-               error(185);
+               error(185, tyname(lbuf, sizeof(lbuf), ltp), 
+                   tyname(rbuf, sizeof(rbuf), rtp));
                break;
        case RETURN:
                /* return value type mismatch */
-               error(211);



Home | Main Index | Thread Index | Old Index