summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-12-09 03:34:35 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-12-09 03:34:35 +0000
commit9c4f20376d34330977e6a9eaac16c930016534f9 (patch)
tree29e74d084a3eb26e8b281be2a3d329d29d959cc5
parentabe10639b5d00e010e3ea754b9abcbe3492bb5c6 (diff)
Test how lint deals with warning for signed/unsigned char conversions
involving character literals (as opposed to literals of other integral types).
-rw-r--r--regress/usr.bin/xlint/test-10.c32
-rw-r--r--regress/usr.bin/xlint/test-10.c.exp3
2 files changed, 15 insertions, 20 deletions
diff --git a/regress/usr.bin/xlint/test-10.c b/regress/usr.bin/xlint/test-10.c
index 803c04f0d23..cacd4094ce6 100644
--- a/regress/usr.bin/xlint/test-10.c
+++ b/regress/usr.bin/xlint/test-10.c
@@ -1,27 +1,23 @@
-/* $OpenBSD: test-10.c,v 1.1 2005/12/02 21:24:09 grunk Exp $ */
+/* $OpenBSD: test-10.c,v 1.2 2005/12/09 03:34:34 cloder Exp $ */
/*
- * Placed in the public domain by Alexander von Gernler <grunk@openbsd.org>
+ * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
*
- * Test if lint keywords in #define macros are preserved
+ * Test lint warning about literal char assignments.
*/
-
-/* ARGSUSED */
-void
-foo(int bar) {
-}
-
-#define S(x) do { foo(x); } while (/* CONSTCOND */ 0)
-#define T(x) do { foo(x); } while (0)
+#include <limits.h>
/* ARGSUSED */
int
-main(int argc, char *argv[]) {
- S(1);
- T(1);
+main(int argc, char *argv[])
+{
+ unsigned char c;
- do { foo(1); } while (/* CONSTCOND */ 0);
- do { foo(1); } while (0);
-
- return (0);
+ c = '\377'; /* should not warn, because c is a char type */
+ c = -1; /* should warn, because rvalue is not a char literal */
+ c++;
+
+ return 0;
}
+
+
diff --git a/regress/usr.bin/xlint/test-10.c.exp b/regress/usr.bin/xlint/test-10.c.exp
index c739707fc42..6350782175e 100644
--- a/regress/usr.bin/xlint/test-10.c.exp
+++ b/regress/usr.bin/xlint/test-10.c.exp
@@ -1,3 +1,2 @@
-test-10.c(21): warning: constant in conditional context
-test-10.c(24): warning: constant in conditional context
+test-10.c(17): warning: assignment of negative constant to unsigned type
Lint pass2: