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: error out on declarations with imp...
details: https://anonhg.NetBSD.org/src/rev/26fcd6b36d3d
branches: trunk
changeset: 365785:26fcd6b36d3d
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 24 20:08:22 2022 +0000
description:
lint: error out on declarations with implicit int type
diffstat:
tests/usr.bin/xlint/lint1/d_compound_literals1.c | 4 ++--
tests/usr.bin/xlint/lint1/d_compound_literals2.c | 4 ++--
tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c | 4 ++--
tests/usr.bin/xlint/lint1/decl.c | 5 ++++-
tests/usr.bin/xlint/lint1/decl.exp | 13 ++++++++-----
tests/usr.bin/xlint/lint1/msg_001.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_001.exp | 2 ++
tests/usr.bin/xlint/lint1/msg_032.c | 3 ++-
tests/usr.bin/xlint/lint1/msg_032.exp | 7 ++++---
tests/usr.bin/xlint/lint1/msg_053.c | 3 ++-
tests/usr.bin/xlint/lint1/msg_053.exp | 3 ++-
tests/usr.bin/xlint/lint1/msg_062.c | 3 ++-
tests/usr.bin/xlint/lint1/msg_062.exp | 5 +++--
tests/usr.bin/xlint/lint1/msg_216.c | 4 ++--
tests/usr.bin/xlint/lint1/msg_216.exp | 1 +
tests/usr.bin/xlint/lint1/msg_250.c | 9 ++++++---
tests/usr.bin/xlint/lint1/msg_250.exp | 5 +++--
usr.bin/xlint/lint1/cgram.y | 18 ++++++++++++------
18 files changed, 62 insertions(+), 37 deletions(-)
diffs (truncated from 305 to 300 lines):
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/d_compound_literals1.c
--- a/tests/usr.bin/xlint/lint1/d_compound_literals1.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_compound_literals1.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_compound_literals1.c,v 1.3 2021/01/31 14:57:28 rillig Exp $ */
+/* $NetBSD: d_compound_literals1.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */
# 3 "d_compound_literals1.c"
/* compound literals */
@@ -7,7 +7,7 @@
short a, b, c, d;
};
-foo()
+void foo(void)
{
struct p me = (struct p){ 1, 2, 3, 4 };
me.a = me.b;
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/d_compound_literals2.c
--- a/tests/usr.bin/xlint/lint1/d_compound_literals2.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_compound_literals2.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_compound_literals2.c,v 1.3 2021/01/31 14:57:28 rillig Exp $ */
+/* $NetBSD: d_compound_literals2.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */
# 3 "d_compound_literals2.c"
/* compound literals */
@@ -16,7 +16,7 @@
return &q[i];
}
-foo()
+void foo(void)
{
*bar(1) = (struct p){ 1, 2, 3, 4 };
}
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
--- a/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: d_gcc_compound_statements1.c,v 1.8 2022/04/03 00:39:32 rillig Exp $ */
+/* $NetBSD: d_gcc_compound_statements1.c,v 1.9 2022/04/24 20:08:23 rillig Exp $ */
# 3 "d_gcc_compound_statements1.c"
/* GCC compound statement with expression */
-foo(unsigned long z)
+void foo(unsigned long z)
{
z = ({
unsigned long tmp;
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/decl.c
--- a/tests/usr.bin/xlint/lint1/decl.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/decl.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.14 2022/04/24 19:21:01 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.15 2022/04/24 20:08:23 rillig Exp $ */
# 3 "decl.c"
/*
@@ -159,12 +159,15 @@
sizeof(const typeof(unsigned_long)) +
sizeof(const typeof(unnamed_struct));
+/* expect+2: error: old style declaration; add 'int' [1] */
/* expect+1: syntax error 'int' [249] */
thread int thread_int;
__thread int thread_int;
+/* expect+2: error: old style declaration; add 'int' [1] */
/* expect+1: syntax error 'int' [249] */
__thread__ int thread_int;
+/* expect+4: error: old style declaration; add 'int' [1] */
/* expect+2: warning: static function cover_func_declarator unused [236] */
static
cover_func_declarator(void)
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/decl.exp
--- a/tests/usr.bin/xlint/lint1/decl.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/decl.exp Sun Apr 24 20:08:22 2022 +0000
@@ -10,9 +10,12 @@
decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]
decl.c(80): error: syntax error '"' [249]
decl.c(106): error: old style declaration; add 'int' [1]
-decl.c(163): error: syntax error 'int' [249]
-decl.c(166): error: syntax error 'int' [249]
-decl.c(180): error: syntax error 'goto' [249]
+decl.c(164): error: old style declaration; add 'int' [1]
+decl.c(164): error: syntax error 'int' [249]
+decl.c(168): error: old style declaration; add 'int' [1]
+decl.c(168): error: syntax error 'int' [249]
+decl.c(174): error: old style declaration; add 'int' [1]
+decl.c(183): error: syntax error 'goto' [249]
decl.c(114): warning: static function unused unused [236]
-decl.c(170): warning: static function cover_func_declarator unused [236]
-decl.c(180): warning: empty array declaration: void_array_error [190]
+decl.c(173): warning: static function cover_func_declarator unused [236]
+decl.c(183): warning: empty array declaration: void_array_error [190]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_001.c
--- a/tests/usr.bin/xlint/lint1/msg_001.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_001.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_001.c,v 1.5 2022/04/24 19:46:29 rillig Exp $ */
+/* $NetBSD: msg_001.c,v 1.6 2022/04/24 20:08:23 rillig Exp $ */
# 3 "msg_001.c"
// Test for message: old style declaration; add 'int' [1]
@@ -15,12 +15,12 @@
/* expect+1: warning: static variable static_new_style unused [226] */
static int static_new_style = 1;
-/* TODO: complain about missing 'int' */
+/* expect+2: error: old style declaration; add 'int' [1] */
extern_implicit_int(void)
{
}
-/* TODO: complain about missing 'int' */
+/* expect+4: error: old style declaration; add 'int' [1] */
/* expect+2: warning: static function static_implicit_int unused [236] */
static
static_implicit_int(void)
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_001.exp
--- a/tests/usr.bin/xlint/lint1/msg_001.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_001.exp Sun Apr 24 20:08:22 2022 +0000
@@ -1,5 +1,7 @@
msg_001.c(7): warning: old style declaration; add 'int' [1]
msg_001.c(13): error: old style declaration; add 'int' [1]
+msg_001.c(20): error: old style declaration; add 'int' [1]
+msg_001.c(27): error: old style declaration; add 'int' [1]
msg_001.c(13): warning: static variable static_old_style unused [226]
msg_001.c(16): warning: static variable static_new_style unused [226]
msg_001.c(26): warning: static function static_implicit_int unused [236]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_032.c
--- a/tests/usr.bin/xlint/lint1/msg_032.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_032.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,8 +1,9 @@
-/* $NetBSD: msg_032.c,v 1.3 2022/04/05 23:09:19 rillig Exp $ */
+/* $NetBSD: msg_032.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */
# 3 "msg_032.c"
// Test for message: argument type defaults to 'int': %s [32]
+/* expect+5: error: old style declaration; add 'int' [1] */
add(a, b, c)
/* expect+3: warning: argument type defaults to 'int': a [32] */
/* expect+2: warning: argument type defaults to 'int': b [32] */
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_032.exp
--- a/tests/usr.bin/xlint/lint1/msg_032.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_032.exp Sun Apr 24 20:08:22 2022 +0000
@@ -1,3 +1,4 @@
-msg_032.c(10): warning: argument type defaults to 'int': a [32]
-msg_032.c(10): warning: argument type defaults to 'int': b [32]
-msg_032.c(10): warning: argument type defaults to 'int': c [32]
+msg_032.c(11): error: old style declaration; add 'int' [1]
+msg_032.c(11): warning: argument type defaults to 'int': a [32]
+msg_032.c(11): warning: argument type defaults to 'int': b [32]
+msg_032.c(11): warning: argument type defaults to 'int': c [32]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_053.c
--- a/tests/usr.bin/xlint/lint1/msg_053.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_053.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,8 +1,9 @@
-/* $NetBSD: msg_053.c,v 1.3 2021/08/27 20:16:50 rillig Exp $ */
+/* $NetBSD: msg_053.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */
# 3 "msg_053.c"
// Test for message: declared argument %s is missing [53]
+/* expect+2: error: old style declaration; add 'int' [1] */
oldstyle(argument)
int argument;
/* expect+1: error: declared argument extra_argument is missing [53] */
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_053.exp
--- a/tests/usr.bin/xlint/lint1/msg_053.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_053.exp Sun Apr 24 20:08:22 2022 +0000
@@ -1,1 +1,2 @@
-msg_053.c(9): error: declared argument extra_argument is missing [53]
+msg_053.c(8): error: old style declaration; add 'int' [1]
+msg_053.c(10): error: declared argument extra_argument is missing [53]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_062.c
--- a/tests/usr.bin/xlint/lint1/msg_062.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_062.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,8 +1,9 @@
-/* $NetBSD: msg_062.c,v 1.3 2022/02/27 20:02:44 rillig Exp $ */
+/* $NetBSD: msg_062.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */
# 3 "msg_062.c"
// Test for message: function prototype parameters must have types [62]
+/* expect+1: error: old style declaration; add 'int' [1] */
outer() {
/* expect+2: warning: function prototype parameters must have types [62] */
/* expect+1: warning: dubious static function at block level: inner [93] */
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_062.exp
--- a/tests/usr.bin/xlint/lint1/msg_062.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_062.exp Sun Apr 24 20:08:22 2022 +0000
@@ -1,2 +1,3 @@
-msg_062.c(9): warning: function prototype parameters must have types [62]
-msg_062.c(9): warning: dubious static function at block level: inner [93]
+msg_062.c(7): error: old style declaration; add 'int' [1]
+msg_062.c(10): warning: function prototype parameters must have types [62]
+msg_062.c(10): warning: dubious static function at block level: inner [93]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_216.c
--- a/tests/usr.bin/xlint/lint1/msg_216.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_216.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: msg_216.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
+/* $NetBSD: msg_216.c,v 1.3 2022/04/24 20:08:23 rillig Exp $ */
# 3 "msg_216.c"
// Test for message: function %s has return (e); and return; [216]
-/* implicit int */
+/* expect+2: error: old style declaration; add 'int' [1] */
random(int n)
{
if (n < 0)
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_216.exp
--- a/tests/usr.bin/xlint/lint1/msg_216.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_216.exp Sun Apr 24 20:08:22 2022 +0000
@@ -1,1 +1,2 @@
+msg_216.c(8): error: old style declaration; add 'int' [1]
msg_216.c(13): warning: function random has return (e); and return; [216]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_250.c
--- a/tests/usr.bin/xlint/lint1/msg_250.c Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_250.c Sun Apr 24 20:08:22 2022 +0000
@@ -1,7 +1,10 @@
-/* $NetBSD: msg_250.c,v 1.3 2021/06/29 07:17:43 rillig Exp $ */
+/* $NetBSD: msg_250.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */
# 3 "msg_250.c"
// Test for message: unknown character \%o [250]
-@deprecated /* expect: unknown character \100 [250] */
-char *gets(void); /* expect: syntax error 'char' [249] */
+/* expect+1: unknown character \100 [250] */
+@deprecated
+/* expect+2: error: old style declaration; add 'int' [1] */
+/* expect+1: syntax error 'char' [249] */
+char *gets(void);
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d tests/usr.bin/xlint/lint1/msg_250.exp
--- a/tests/usr.bin/xlint/lint1/msg_250.exp Sun Apr 24 19:46:29 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_250.exp Sun Apr 24 20:08:22 2022 +0000
@@ -1,2 +1,3 @@
-msg_250.c(6): error: unknown character \100 [250]
-msg_250.c(7): error: syntax error 'char' [249]
+msg_250.c(7): error: unknown character \100 [250]
+msg_250.c(10): error: old style declaration; add 'int' [1]
+msg_250.c(10): error: syntax error 'char' [249]
diff -r 9f479f7c4ef0 -r 26fcd6b36d3d usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Apr 24 19:46:29 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Apr 24 20:08:22 2022 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.401 2022/04/24 19:21:01 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.402 2022/04/24 20:08:22 rillig 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: cgram.y,v 1.401 2022/04/24 19:21:01 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.402 2022/04/24 20:08:22 rillig Exp $");
#endif
#include <limits.h>
@@ -416,7 +416,7 @@
/* K&R 7.1, C90 ???, C99 6.5.1, C11 6.5.1 */
primary_expression:
T_NAME {
- bool sys_name, sys_next;
+ bool sys_name, sys_next;
sys_name = in_system_header;
if (yychar < 0)
yychar = yylex();
@@ -1597,7 +1597,7 @@
static_assert_declaration:
T_STATIC_ASSERT T_LPAREN constant_expr T_COMMA T_STRING T_RPAREN T_SEMI /* C11 */
| T_STATIC_ASSERT T_LPAREN constant_expr T_RPAREN T_SEMI /* C23 */
- ;
+ ;
range:
constant_expr {
@@ -1990,11 +1990,17 @@
func_declarator:
begin_type end_type notype_declarator {
- /* ^^ There is no check for the missing type-specifier. */
+ if (!allow_trad) {
+ /* old style declaration; add 'int' */
+ error(1);
+ }
$$ = $3;
}
| begin_type_declmods end_type notype_declarator {
- /* ^^ There is no check for the missing type-specifier. */
+ if (!allow_trad) {
+ /* old style declaration; add 'int' */
Home |
Main Index |
Thread Index |
Old Index