Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: add tests for more unc...



details:   https://anonhg.NetBSD.org/src/rev/5cf923d6eecf
branches:  trunk
changeset: 985264:5cf923d6eecf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 15 14:00:27 2021 +0000

description:
tests/lint: add tests for more unconst functions

diffstat:

 tests/usr.bin/xlint/lint1/msg_346.c   |  25 +++++++++++++++++++++++--
 tests/usr.bin/xlint/lint1/msg_346.exp |   5 +++--
 2 files changed, 26 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r 3cb5b236b869 -r 5cf923d6eecf tests/usr.bin/xlint/lint1/msg_346.c
--- a/tests/usr.bin/xlint/lint1/msg_346.c       Sun Aug 15 13:32:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_346.c       Sun Aug 15 14:00:27 2021 +0000
@@ -1,9 +1,15 @@
-/*     $NetBSD: msg_346.c,v 1.1 2021/08/09 20:07:24 rillig Exp $       */
+/*     $NetBSD: msg_346.c,v 1.2 2021/08/15 14:00:27 rillig Exp $       */
 # 3 "msg_346.c"
 
 // Test for message: call to '%s' effectively discards 'const' from argument [346]
 
-char *strchr(const char *, int);
+typedef unsigned long size_t;
+
+void* memchr(const void *, int, size_t);               /* C99 7.21.5.1 */
+char *strchr(const char *, int);                       /* C99 7.21.5.2 */
+char* strpbrk(const char *, const char *);             /* C99 7.21.5.4 */
+char* strrchr(const char *, int);                      /* C99 7.21.5.5 */
+char* strstr(const char *, const char *);              /* C99 7.21.5.7 */
 
 void take_const_char_ptr(const char *);
 void take_char_ptr(char *);
@@ -30,3 +36,18 @@
        /* expect+1: warning: call to 'strchr' effectively discards 'const' from argument [346] */
        take_char_ptr(strchr("literal", 'c'));
 }
+
+void
+all_functions(void)
+{
+       /* TODO: expect+1: warning: call to 'memchr' effectively discards 'const' from argument [346] */
+       take_char_ptr(memchr("string", 'c', 7));
+       /* expect+1: warning: call to 'strchr' effectively discards 'const' from argument [346] */
+       take_char_ptr(strchr("string", 'c'));
+       /* TODO: expect+1: warning: call to 'strpbrk' effectively discards 'const' from argument [346] */
+       take_char_ptr(strpbrk("string", "c"));
+       /* TODO: expect+1: warning: call to 'strrchr' effectively discards 'const' from argument [346] */
+       take_char_ptr(strrchr("string", 'c'));
+       /* TODO: expect+1: warning: call to 'strstr' effectively discards 'const' from argument [346] */
+       take_char_ptr(strstr("string", "c"));
+}
diff -r 3cb5b236b869 -r 5cf923d6eecf tests/usr.bin/xlint/lint1/msg_346.exp
--- a/tests/usr.bin/xlint/lint1/msg_346.exp     Sun Aug 15 13:32:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_346.exp     Sun Aug 15 14:00:27 2021 +0000
@@ -1,3 +1,4 @@
-msg_346.c(20): warning: call to 'strchr' effectively discards 'const' from argument [346]
 msg_346.c(26): warning: call to 'strchr' effectively discards 'const' from argument [346]
-msg_346.c(31): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(32): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(37): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(46): warning: call to 'strchr' effectively discards 'const' from argument [346]



Home | Main Index | Thread Index | Old Index