Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: demonstrate wrong lint warning about complex var...
details: https://anonhg.NetBSD.org/src/rev/255911286e8a
branches: trunk
changeset: 954439:255911286e8a
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Apr 09 21:07:39 2021 +0000
description:
tests/lint: demonstrate wrong lint warning about complex variables
diffstat:
distrib/sets/lists/tests/mi | 3 +-
tests/usr.bin/xlint/lint1/Makefile | 3 +-
tests/usr.bin/xlint/lint1/d_c99_complex_split.c | 34 ++++++++++++++++++++++-
tests/usr.bin/xlint/lint1/d_c99_complex_split.exp | 3 ++
4 files changed, 40 insertions(+), 3 deletions(-)
diffs (86 lines):
diff -r 4024e48fa1e7 -r 255911286e8a distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Apr 09 20:49:05 2021 +0000
+++ b/distrib/sets/lists/tests/mi Fri Apr 09 21:07:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1038 2021/04/08 22:18:26 rillig Exp $
+# $NetBSD: mi,v 1.1039 2021/04/09 21:07:39 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6104,6 +6104,7 @@
./usr/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_complex_num.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_complex_split.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_c99_complex_split.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c tests-usr.bin-tests compattestfile,atf
diff -r 4024e48fa1e7 -r 255911286e8a tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Fri Apr 09 20:49:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Fri Apr 09 21:07:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.40 2021/04/08 22:18:27 rillig Exp $
+# $NetBSD: Makefile,v 1.41 2021/04/09 21:07:39 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 342 # see lint1/err.c
@@ -22,6 +22,7 @@
FILES+= d_c99_anon_union.c
FILES+= d_c99_complex_num.c
FILES+= d_c99_complex_split.c
+FILES+= d_c99_complex_split.exp
FILES+= d_c99_compound_literal_comma.c
FILES+= d_c99_decls_after_stmt.c
FILES+= d_c99_decls_after_stmt2.c
diff -r 4024e48fa1e7 -r 255911286e8a tests/usr.bin/xlint/lint1/d_c99_complex_split.c
--- a/tests/usr.bin/xlint/lint1/d_c99_complex_split.c Fri Apr 09 20:49:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_complex_split.c Fri Apr 09 21:07:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_complex_split.c,v 1.5 2021/03/27 13:59:18 rillig Exp $ */
+/* $NetBSD: d_c99_complex_split.c,v 1.6 2021/04/09 21:07:39 rillig Exp $ */
# 3 "d_c99_complex_split.c"
/*
@@ -19,3 +19,35 @@
if (b(__real__ z) && b(__imag__ z))
return;
}
+
+void sink(double _Complex);
+
+void
+set_complex_complete(double re, double im)
+{
+ double _Complex c;
+
+ __real__ c = re; /* FIXME *//* expect: may be used before set */
+ __imag__ c = im;
+ sink(c);
+}
+
+void
+set_complex_only_real(double re)
+{
+ double _Complex c;
+
+ __real__ c = re; /* FIXME *//* expect: may be used before set */
+ /* __imag__ c is left uninitialized */
+ sink(c); /* XXX: may be used before set */
+}
+
+void
+set_complex_only_imag(double im)
+{
+ double _Complex c;
+
+ /* __real__ c is left uninitialized */
+ __imag__ c = im; /* FIXME *//* expect: may be used before set */
+ sink(c); /* XXX: may be used before set */
+}
diff -r 4024e48fa1e7 -r 255911286e8a tests/usr.bin/xlint/lint1/d_c99_complex_split.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_complex_split.exp Fri Apr 09 21:07:39 2021 +0000
@@ -0,0 +1,3 @@
+d_c99_complex_split.c(30): warning: c may be used before set [158]
+d_c99_complex_split.c(40): warning: c may be used before set [158]
+d_c99_complex_split.c(51): warning: c may be used before set [158]
Home |
Main Index |
Thread Index |
Old Index