Module Name: src
Committed By: rillig
Date: Sun Mar 28 15:36:37 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_050.exp msg_054.exp msg_081.exp
msg_082.exp msg_100.exp msg_186.exp msg_188.exp msg_189.c
msg_189.exp msg_219.exp
src/usr.bin/xlint/lint1: main1.c
Log Message:
lint: only define GCC builtins if -g is given
This removes 7 wrong warnings when running lint in -t mode.
Surprisingly, this added a warning that had not been there before in
msg_189.c. This is because check_variable_usage skips the checks when
an error occurred before. All diagnostics that happened were warnings,
but the -w option treats them as errors, see vwarning.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_050.exp \
src/tests/usr.bin/xlint/lint1/msg_054.exp \
src/tests/usr.bin/xlint/lint1/msg_081.exp \
src/tests/usr.bin/xlint/lint1/msg_082.exp \
src/tests/usr.bin/xlint/lint1/msg_100.exp \
src/tests/usr.bin/xlint/lint1/msg_189.c \
src/tests/usr.bin/xlint/lint1/msg_189.exp \
src/tests/usr.bin/xlint/lint1/msg_219.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_186.exp \
src/tests/usr.bin/xlint/lint1/msg_188.exp
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/lint1/main1.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_050.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_050.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_050.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_050.exp:1.2 Fri Jan 8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_050.exp Sun Mar 28 15:36:37 2021
@@ -1,9 +1,2 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_050.c(11): warning: a function is declared as an argument: f [50]
msg_050.c(10): warning: argument f unused in function example [231]
Index: src/tests/usr.bin/xlint/lint1/msg_054.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_054.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_054.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_054.exp:1.2 Fri Jan 8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_054.exp Sun Mar 28 15:36:37 2021
@@ -1,8 +1 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_054.c(12): warning: trailing ',' prohibited in enum declaration [54]
Index: src/tests/usr.bin/xlint/lint1/msg_081.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_081.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_081.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_081.exp:1.2 Fri Jan 8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_081.exp Sun Mar 28 15:36:37 2021
@@ -1,8 +1 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_081.c(8): warning: \a undefined in traditional C [81]
Index: src/tests/usr.bin/xlint/lint1/msg_082.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_082.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_082.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_082.exp:1.2 Fri Jan 8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_082.exp Sun Mar 28 15:36:37 2021
@@ -1,8 +1 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_082.c(8): warning: \x undefined in traditional C [82]
Index: src/tests/usr.bin/xlint/lint1/msg_100.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_100.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_100.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_100.exp:1.2 Fri Jan 8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_100.exp Sun Mar 28 15:36:37 2021
@@ -1,9 +1,2 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_100.c(10): warning: function prototypes are illegal in traditional C [270]
msg_100.c(11): warning: unary + is illegal in traditional C [100]
Index: src/tests/usr.bin/xlint/lint1/msg_189.c
diff -u src/tests/usr.bin/xlint/lint1/msg_189.c:1.2 src/tests/usr.bin/xlint/lint1/msg_189.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_189.c:1.2 Sat Jan 30 17:56:29 2021
+++ src/tests/usr.bin/xlint/lint1/msg_189.c Sun Mar 28 15:36:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_189.c,v 1.2 2021/01/30 17:56:29 rillig Exp $ */
+/* $NetBSD: msg_189.c,v 1.3 2021/03/28 15:36:37 rillig Exp $ */
# 3 "msg_189.c"
/* Test for message: assignment of struct/union illegal in traditional C [189] */
@@ -16,4 +16,5 @@ example()
a.member = 3;
b = a; /* message 189 is not triggered anymore */
+ /* expect-1: b set but not used in function example */
}
Index: src/tests/usr.bin/xlint/lint1/msg_189.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_189.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_189.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_189.exp:1.2 Sat Jan 30 17:56:29 2021
+++ src/tests/usr.bin/xlint/lint1/msg_189.exp Sun Mar 28 15:36:37 2021
@@ -1,7 +1 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
+msg_189.c(18): warning: b set but not used in function example [191]
Index: src/tests/usr.bin/xlint/lint1/msg_219.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_219.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_219.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_219.exp:1.2 Sat Jan 2 11:12:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_219.exp Sun Mar 28 15:36:37 2021
@@ -1,10 +1,3 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_219.c(10): warning: concatenated strings are illegal in traditional C [219]
msg_219.c(11): warning: concatenated strings are illegal in traditional C [219]
msg_219.c(12): warning: concatenated strings are illegal in traditional C [219]
Index: src/tests/usr.bin/xlint/lint1/msg_186.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_186.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_186.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_186.exp:1.3 Mon Feb 22 15:09:50 2021
+++ src/tests/usr.bin/xlint/lint1/msg_186.exp Sun Mar 28 15:36:37 2021
@@ -1,8 +1 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_186.c(16): warning: bit-field initialization is illegal in traditional C [186]
Index: src/tests/usr.bin/xlint/lint1/msg_188.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_188.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_188.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_188.exp:1.3 Sun Mar 28 15:12:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_188.exp Sun Mar 28 15:36:37 2021
@@ -1,8 +1 @@
-(1): warning: 'long double' is illegal in traditional C [266]
-(1): warning: function prototypes are illegal in traditional C [270]
-(2): warning: 'long double' is illegal in traditional C [266]
-(2): warning: function prototypes are illegal in traditional C [270]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: 'long double' is illegal in traditional C [266]
-(3): warning: function prototypes are illegal in traditional C [270]
msg_188.c(21): warning: no automatic aggregate initialization in traditional C [188]
Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.40 src/usr.bin/xlint/lint1/main1.c:1.41
--- src/usr.bin/xlint/lint1/main1.c:1.40 Sat Mar 27 11:50:34 2021
+++ src/usr.bin/xlint/lint1/main1.c Sun Mar 28 15:36:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.40 2021/03/27 11:50:34 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.41 2021/03/28 15:36:37 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.40 2021/03/27 11:50:34 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.41 2021/03/28 15:36:37 rillig Exp $");
#endif
#include <sys/types.h>
@@ -138,7 +138,7 @@ static const char builtins[] =
static const size_t builtinlen = sizeof builtins - 1;
static FILE *
-bltin(void)
+gcc_builtins(void)
{
#if HAVE_NBTOOL_CONFIG_H
char template[] = "/tmp/lint.XXXXXX";
@@ -254,10 +254,12 @@ main(int argc, char *argv[])
initdecl();
initscan();
- if ((yyin = bltin()) == NULL)
- err(1, "cannot open builtins");
- yyparse();
- fclose(yyin);
+ if (gflag) {
+ if ((yyin = gcc_builtins()) == NULL)
+ err(1, "cannot open builtins");
+ yyparse();
+ fclose(yyin);
+ }
/* open the input file */
if ((yyin = fopen(argv[0], "r")) == NULL)