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: document why C11 keywords are avai...



details:   https://anonhg.NetBSD.org/src/rev/e4d4219923f6
branches:  trunk
changeset: 365883:e4d4219923f6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 30 20:24:57 2022 +0000

description:
lint: document why C11 keywords are available in C99 mode as well

diffstat:

 tests/usr.bin/xlint/lint1/msg_010.c   |  11 +++++++----
 tests/usr.bin/xlint/lint1/msg_010.exp |   6 +++---
 usr.bin/xlint/lint1/externs1.h        |   3 +--
 usr.bin/xlint/lint1/lex.c             |  17 ++++++++++++-----
 4 files changed, 23 insertions(+), 14 deletions(-)

diffs (105 lines):

diff -r 1bcb722bb09b -r e4d4219923f6 tests/usr.bin/xlint/lint1/msg_010.c
--- a/tests/usr.bin/xlint/lint1/msg_010.c       Sat Apr 30 19:53:37 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_010.c       Sat Apr 30 20:24:57 2022 +0000
@@ -1,20 +1,23 @@
-/*     $NetBSD: msg_010.c,v 1.4 2021/01/18 17:43:44 rillig Exp $       */
+/*     $NetBSD: msg_010.c,v 1.5 2022/04/30 20:24:57 rillig Exp $       */
 # 3 "msg_010.c"
 
 // Test for message: duplicate '%s' [10]
 
-inline inline void             /* expect: [10] */
+/* expect+1: warning: duplicate 'inline' [10] */
+inline inline void
 double_inline(void)
 {
 }
 
-const const int                        /* expect: [10] */
+/* expect+1: warning: duplicate 'const' [10] */
+const const int
 double_const(void)
 {
        return 0;
 }
 
-volatile volatile int          /* expect: [10] */
+/* expect+1: warning: duplicate 'volatile' [10] */
+volatile volatile int
 double_volatile(void)
 {
        return 0;
diff -r 1bcb722bb09b -r e4d4219923f6 tests/usr.bin/xlint/lint1/msg_010.exp
--- a/tests/usr.bin/xlint/lint1/msg_010.exp     Sat Apr 30 19:53:37 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_010.exp     Sat Apr 30 20:24:57 2022 +0000
@@ -1,3 +1,3 @@
-msg_010.c(6): warning: duplicate 'inline' [10]
-msg_010.c(11): warning: duplicate 'const' [10]
-msg_010.c(17): warning: duplicate 'volatile' [10]
+msg_010.c(7): warning: duplicate 'inline' [10]
+msg_010.c(13): warning: duplicate 'const' [10]
+msg_010.c(20): warning: duplicate 'volatile' [10]
diff -r 1bcb722bb09b -r e4d4219923f6 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Sat Apr 30 19:53:37 2022 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Sat Apr 30 20:24:57 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.157 2022/04/30 18:51:00 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.158 2022/04/30 20:24:57 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -68,7 +68,6 @@
  */
 #define tflag  (allow_trad && !allow_c90)
 #define sflag  (!allow_trad && !allow_c99)
-#define Sflag  allow_c99
 
 extern void    norecover(void);
 
diff -r 1bcb722bb09b -r e4d4219923f6 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Apr 30 19:53:37 2022 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Apr 30 20:24:57 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.124 2022/04/30 19:53:37 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.125 2022/04/30 20:24:57 rillig 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: lex.c,v 1.124 2022/04/30 19:53:37 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.125 2022/04/30 20:24:57 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -67,7 +67,14 @@
 bool in_gcc_attribute;
 bool in_system_header;
 
-/* Valid values for 'since' are 78, 90, 99, 11. */
+/*
+ * Valid values for 'since' are 78, 90, 99, 11.
+ *
+ * As of 2022-04-30, lint treats 11 like 99, in order to provide good error
+ * messages instead of a simple parse error.  If the keyword '_Generic' were
+ * not defined, it would be interpreted as an implicit function call, leading
+ * to a parse error.
+ */
 #define kwdef(name, token, scl, tspec, tqual,  since, gcc, attr, deco) \
        { \
                name, token, scl, tspec, tqual, \
@@ -418,10 +425,10 @@
 
        end = keywords + sizeof(keywords) / sizeof(keywords[0]);
        for (kw = keywords; kw != end; kw++) {
-               if ((kw->kw_c90 || kw->kw_c99) && tflag)
+               if ((kw->kw_c90 || kw->kw_c99) && !allow_c90)
                        continue;
                /* FIXME: C99 and GCC are independent. */
-               if (kw->kw_c99 && !(Sflag || allow_gcc))
+               if (kw->kw_c99 && !(allow_c99 || allow_gcc))
                        continue;
                if (kw->kw_gcc && !allow_gcc)
                        continue;



Home | Main Index | Thread Index | Old Index