Module Name:    src
Committed By:   rillig
Date:           Sun Aug 15 14:00:27 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_346.c msg_346.exp

Log Message:
tests/lint: add tests for more unconst functions


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_346.c \
    src/tests/usr.bin/xlint/lint1/msg_346.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_346.c
diff -u src/tests/usr.bin/xlint/lint1/msg_346.c:1.1 src/tests/usr.bin/xlint/lint1/msg_346.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_346.c:1.1	Mon Aug  9 20:07:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.c	Sun Aug 15 14:00:27 2021
@@ -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 @@ example(void)
 	/* 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"));
+}
Index: src/tests/usr.bin/xlint/lint1/msg_346.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_346.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_346.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_346.exp:1.1	Mon Aug  9 20:07:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.exp	Sun Aug 15 14:00:27 2021
@@ -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]

Reply via email to