Module Name: src Committed By: christos Date: Fri Sep 7 15:16:15 UTC 2018
Modified Files: src/usr.bin/xlint/common: inittyp.c lint.h lp64.h tyname.c src/usr.bin/xlint/lint1: decl.c err.c scan.l tree.c src/usr.bin/xlint/lint2: read.c Log Message: recognize int128 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.4 -r1.5 src/usr.bin/xlint/common/lp64.h cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.68 -r1.69 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.82 -r1.83 src/usr.bin/xlint/lint1/scan.l cvs rdiff -u -r1.85 -r1.86 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/common/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.11 src/usr.bin/xlint/common/inittyp.c:1.12 --- src/usr.bin/xlint/common/inittyp.c:1.11 Tue Apr 14 21:20:57 2009 +++ src/usr.bin/xlint/common/inittyp.c Fri Sep 7 11:16:15 2018 @@ -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 @@ inittyp(void) { 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" } }, Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.13 src/usr.bin/xlint/common/lint.h:1.14 --- src/usr.bin/xlint/common/lint.h:1.13 Tue Apr 14 21:20:57 2009 +++ src/usr.bin/xlint/common/lint.h Fri Sep 7 11:16:15 2018 @@ -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 @@ typedef enum { 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 */ Index: src/usr.bin/xlint/common/lp64.h diff -u src/usr.bin/xlint/common/lp64.h:1.4 src/usr.bin/xlint/common/lp64.h:1.5 --- src/usr.bin/xlint/common/lp64.h:1.4 Tue Mar 27 15:24:03 2012 +++ src/usr.bin/xlint/common/lp64.h Fri Sep 7 11:16:15 2018 @@ -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) Index: src/usr.bin/xlint/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.12 src/usr.bin/xlint/common/tyname.c:1.13 --- src/usr.bin/xlint/common/tyname.c:1.12 Fri Aug 19 06:18:11 2016 +++ src/usr.bin/xlint/common/tyname.c Fri Sep 7 11:16:15 2018 @@ -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 @@ basictyname(tspec_t t) 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 @@ sametype(const type_t *t1, const type_t case ULONG: case QUAD: case UQUAD: +#ifdef INT128_SIZE + case INT128: + case UINT128: +#endif case FLOAT: case DOUBLE: case LDOUBLE: @@ -182,6 +190,10 @@ tyname(char *buf, size_t bufsiz, const t case ULONG: case QUAD: case UQUAD: +#ifdef INT128_SIZE + case INT128: + case UINT128: +#endif case FLOAT: case DOUBLE: case LDOUBLE: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.68 src/usr.bin/xlint/lint1/decl.c:1.69 --- src/usr.bin/xlint/lint1/decl.c:1.68 Mon Mar 6 18:04:52 2017 +++ src/usr.bin/xlint/lint1/decl.c Fri Sep 7 11:16:15 2018 @@ -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 @@ tdeferr(type_t *td, tspec_t t) case DOUBLE: case UQUAD: case QUAD: +#ifdef INT128_SIZE + case UINT128: + case INT128: +#endif case ULONG: case UINT: case INT: Index: src/usr.bin/xlint/lint1/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.52 src/usr.bin/xlint/lint1/err.c:1.53 --- src/usr.bin/xlint/lint1/err.c:1.52 Mon Jan 15 17:14:24 2018 +++ src/usr.bin/xlint/lint1/err.c Fri Sep 7 11:16:15 2018 @@ -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 @@ const char *msgs[] = { "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 @@ const char *msgs[] = { "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 */ Index: src/usr.bin/xlint/lint1/scan.l diff -u src/usr.bin/xlint/lint1/scan.l:1.82 src/usr.bin/xlint/lint1/scan.l:1.83 --- src/usr.bin/xlint/lint1/scan.l:1.82 Sun Jul 8 13:48:42 2018 +++ src/usr.bin/xlint/lint1/scan.l Fri Sep 7 11:16:15 2018 @@ -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 @@ static struct kwtab { 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 @@ icon(int base) const char *cp; char c, *eptr; tspec_t typ; - uint64_t uq = 0; 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; 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 @@ icon(int base) 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: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.85 src/usr.bin/xlint/lint1/tree.c:1.86 --- src/usr.bin/xlint/lint1/tree.c:1.85 Fri Jun 29 16:18:05 2018 +++ src/usr.bin/xlint/lint1/tree.c Fri Sep 7 11:16:15 2018 @@ -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 @@ asgntypok(op_t op, int arg, tnode_t *ln, 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); + error(211, tyname(lbuf, sizeof(lbuf), ltp), + tyname(rbuf, sizeof(rbuf), rtp)); break; case FARG: /* argument is incompatible with prototype, arg #%d */ Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.27 src/usr.bin/xlint/lint2/read.c:1.28 --- src/usr.bin/xlint/lint2/read.c:1.27 Tue Dec 26 12:02:19 2017 +++ src/usr.bin/xlint/lint2/read.c Fri Sep 7 11:16:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.27 2017/12/26 17:02:19 christos Exp $ */ +/* $NetBSD: read.c,v 1.28 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: read.c,v 1.27 2017/12/26 17:02:19 christos Exp $"); +__RCSID("$NetBSD: read.c,v 1.28 2018/09/07 15:16:15 christos Exp $"); #endif #include <ctype.h> @@ -713,6 +713,10 @@ inptype(const char *cp, const char **epp case FLOAT: case UQUAD: case QUAD: +#ifdef INT128_SIZE + case UINT128: + case INT128: +#endif case ULONG: case UINT: case INT: @@ -952,9 +956,13 @@ gettlen(const char *cp, const char **epp case LDOUBLE: case VOID: case ULONG: + case LONG: case QUAD: case UQUAD: - case LONG: +#ifdef INT128_SIZE + case INT128: + case UINT128: +#endif case FCOMPLEX: case DCOMPLEX: case LCOMPLEX: