diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-11-30 12:43:29 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-12-01 02:12:45 +0100 |
| commit | 6f7aa5e84dacec8e27a8d70090bba26a1a1276de (patch) | |
| tree | 231184af511c817eb7c40baf20d9758cb1bf4fd3 /validation | |
| parent | d3038d8fce94959bc9bcbcff698d272d0f610364 (diff) | |
| download | sparse-dev-6f7aa5e84dacec8e27a8d70090bba26a1a1276de.tar.gz | |
fix implicit K&R argument types
In an old-style function definition, if not explicitly specified,
the type of an argument defaults to 'int'.
Sparse issues an error for such arguments and leaves the type
as 'incomplete'. This can then create a cascade of other warnings.
Fix this by effectively giving the type 'int' to such arguments.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/implicit-KR-arg-type1.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/validation/implicit-KR-arg-type1.c b/validation/implicit-KR-arg-type1.c new file mode 100644 index 00000000..fe199ef5 --- /dev/null +++ b/validation/implicit-KR-arg-type1.c @@ -0,0 +1,16 @@ +int foo(a, b) + int a; +{ + if (b) + return a; +} + +/* + * check-name: implicit-KR-arg-type1 + * check-command: sparse -Wold-style-definition -Wimplicit-int $file + * + * check-error-start +implicit-KR-arg-type1.c:2:9: warning: non-ANSI definition of function 'foo' +implicit-KR-arg-type1.c:1:12: error: missing type declaration for parameter 'b' + * check-error-end + */ |
