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 lint: add test for converting non-...



details:   https://anonhg.NetBSD.org/src/rev/a981c23041a6
branches:  trunk
changeset: 1017809:a981c23041a6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 10 12:29:46 2021 +0000

description:
lint: add test for converting non-constant expressions to _Bool

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_bool.c   |  54 +++++++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/d_c99_bool.exp |   2 +
 2 files changed, 55 insertions(+), 1 deletions(-)

diffs (74 lines):

diff -r 7ae729c4fb04 -r a981c23041a6 tests/usr.bin/xlint/lint1/d_c99_bool.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool.c    Sun Jan 10 12:05:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool.c    Sun Jan 10 12:29:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_bool.c,v 1.1 2021/01/10 11:24:42 rillig Exp $    */
+/*     $NetBSD: d_c99_bool.c,v 1.2 2021/01/10 12:29:46 rillig Exp $    */
 # 3 "d_bool.c"
 
 /*
@@ -47,3 +47,55 @@
 
 int double_1_0_converts_to_false[(_Bool)1.0 ? -1 : 1];
 int double_1_0_converts_to_true_[(_Bool)1.0 ? 1 : -1];
+
+_Bool
+bool_to_bool(_Bool b)
+{
+       return b;
+}
+
+_Bool
+char_to_bool(char c)
+{
+       return c;
+}
+
+_Bool
+int_to_bool(int i)
+{
+       return i;
+}
+
+_Bool
+double_to_bool(double d)
+{
+       return d;
+}
+
+enum color {
+       RED
+};
+
+_Bool
+enum_to_bool(enum color e)
+{
+       return e;
+}
+
+_Bool
+pointer_to_bool(const char *p)
+{
+       return p; // FIXME 183
+}
+
+_Bool
+function_pointer_to_bool(void (*f)(void))
+{
+       return f; // FIXME 183
+}
+
+_Bool
+complex_to_bool(double _Complex c)
+{
+       return c;
+}
diff -r 7ae729c4fb04 -r a981c23041a6 tests/usr.bin/xlint/lint1/d_c99_bool.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool.exp  Sun Jan 10 12:05:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool.exp  Sun Jan 10 12:29:46 2021 +0000
@@ -15,3 +15,5 @@
 d_bool.c(42): negative array dimension (-1) [20]
 d_bool.c(46): negative array dimension (-1) [20]
 d_bool.c(48): negative array dimension (-1) [20]
+d_bool.c(88): warning: illegal combination of integer (_Bool) and pointer (pointer to const char) [183]
+d_bool.c(94): warning: illegal combination of integer (_Bool) and pointer (pointer to function() returning void) [183]



Home | Main Index | Thread Index | Old Index