Module Name: src Committed By: rillig Date: Sat Apr 30 20:24:57 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: msg_010.c msg_010.exp src/usr.bin/xlint/lint1: externs1.h lex.c Log Message: lint: document why C11 keywords are available in C99 mode as well To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_010.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_010.exp cvs rdiff -u -r1.157 -r1.158 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_010.c diff -u src/tests/usr.bin/xlint/lint1/msg_010.c:1.4 src/tests/usr.bin/xlint/lint1/msg_010.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_010.c:1.4 Mon Jan 18 17:43:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_010.c Sat Apr 30 20:24:57 2022 @@ -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; Index: src/tests/usr.bin/xlint/lint1/msg_010.exp diff -u src/tests/usr.bin/xlint/lint1/msg_010.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_010.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_010.exp:1.2 Thu Jan 7 18:37:41 2021 +++ src/tests/usr.bin/xlint/lint1/msg_010.exp Sat Apr 30 20:24:57 2022 @@ -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] Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.157 src/usr.bin/xlint/lint1/externs1.h:1.158 --- src/usr.bin/xlint/lint1/externs1.h:1.157 Sat Apr 30 18:51:00 2022 +++ src/usr.bin/xlint/lint1/externs1.h Sat Apr 30 20:24:57 2022 @@ -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 @@ extern bool allow_gcc; */ #define tflag (allow_trad && !allow_c90) #define sflag (!allow_trad && !allow_c99) -#define Sflag allow_c99 extern void norecover(void); Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.124 src/usr.bin/xlint/lint1/lex.c:1.125 --- src/usr.bin/xlint/lint1/lex.c:1.124 Sat Apr 30 19:53:37 2022 +++ src/usr.bin/xlint/lint1/lex.c Sat Apr 30 20:24:57 2022 @@ -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 @@ pos_t csrc_pos = { "", 1, 0 }; 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 @@ initscan(void) 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;