From 9c4f20376d34330977e6a9eaac16c930016534f9 Mon Sep 17 00:00:00 2001 From: Chad Loder Date: Fri, 9 Dec 2005 03:34:35 +0000 Subject: Test how lint deals with warning for signed/unsigned char conversions involving character literals (as opposed to literals of other integral types). --- regress/usr.bin/xlint/test-10.c | 32 ++++++++++++++------------------ regress/usr.bin/xlint/test-10.c.exp | 3 +-- 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'regress/usr.bin') 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 + * Placed in the public domain by Chad Loder . * - * 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 /* 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: -- cgit v1.2.3