Module Name: src Committed By: rillig Date: Sun Jul 25 10:26:46 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_110.c msg_110.exp msg_147.c msg_147.exp Log Message: tests/lint: test function types and pointer arithmetic To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_110.c \ src/tests/usr.bin/xlint/lint1/msg_110.exp \ src/tests/usr.bin/xlint/lint1/msg_147.c \ src/tests/usr.bin/xlint/lint1/msg_147.exp 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_110.c diff -u src/tests/usr.bin/xlint/lint1/msg_110.c:1.2 src/tests/usr.bin/xlint/lint1/msg_110.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_110.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_110.c Sun Jul 25 10:26:46 2021 @@ -1,7 +1,15 @@ -/* $NetBSD: msg_110.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */ +/* $NetBSD: msg_110.c,v 1.3 2021/07/25 10:26:46 rillig Exp $ */ # 3 "msg_110.c" // Test for message: pointer to function is not allowed here [110] -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* ARGSUSED */ +void +call_take(int (*ptr)(int)) +{ + /* expect+1: error: pointer to function is not allowed here [110] */ + ptr++; + + /* expect+1: error: pointer to function is not allowed here [110] */ + ptr + 1; +} Index: src/tests/usr.bin/xlint/lint1/msg_110.exp diff -u src/tests/usr.bin/xlint/lint1/msg_110.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_110.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_110.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_110.exp Sun Jul 25 10:26:46 2021 @@ -1 +1,2 @@ -msg_110.c(6): error: syntax error ':' [249] +msg_110.c(11): error: pointer to function is not allowed here [110] +msg_110.c(14): error: pointer to function is not allowed here [110] Index: src/tests/usr.bin/xlint/lint1/msg_147.c diff -u src/tests/usr.bin/xlint/lint1/msg_147.c:1.2 src/tests/usr.bin/xlint/lint1/msg_147.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_147.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_147.c Sun Jul 25 10:26:46 2021 @@ -1,7 +1,16 @@ -/* $NetBSD: msg_147.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */ +/* $NetBSD: msg_147.c,v 1.3 2021/07/25 10:26:46 rillig Exp $ */ # 3 "msg_147.c" // Test for message: invalid cast expression [147] -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +// The type name 'int(int)' is a 'function(int) returning int'. +void take(int(int)); + +/* ARGSUSED */ +void +call_take(int (*ptr)(int)) +{ + /* XXX: That's a little too unspecific. */ + /* expect+1: error: invalid cast expression [147] */ + take((int(int))ptr); +} Index: src/tests/usr.bin/xlint/lint1/msg_147.exp diff -u src/tests/usr.bin/xlint/lint1/msg_147.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_147.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_147.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_147.exp Sun Jul 25 10:26:46 2021 @@ -1 +1 @@ -msg_147.c(6): error: syntax error ':' [249] +msg_147.c(15): error: invalid cast expression [147]