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 tests/lint: prepare non-GCC test f...
details: https://anonhg.NetBSD.org/src/rev/fe719f0fefc9
branches: trunk
changeset: 1022732:fe719f0fefc9
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Aug 03 20:46:10 2021 +0000
description:
tests/lint: prepare non-GCC test for union casts
diffstat:
tests/usr.bin/xlint/lint1/d_c99_union_cast.c | 14 +++++++++-----
tests/usr.bin/xlint/lint1/d_c99_union_cast.exp | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
diffs (37 lines):
diff -r 1cee7fc75bdc -r fe719f0fefc9 tests/usr.bin/xlint/lint1/d_c99_union_cast.c
--- a/tests/usr.bin/xlint/lint1/d_c99_union_cast.c Tue Aug 03 20:34:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_union_cast.c Tue Aug 03 20:46:10 2021 +0000
@@ -1,8 +1,10 @@
-/* $NetBSD: d_c99_union_cast.c,v 1.5 2021/08/03 20:34:23 rillig Exp $ */
+/* $NetBSD: d_c99_union_cast.c,v 1.6 2021/08/03 20:46:10 rillig Exp $ */
# 3 "d_c99_union_cast.c"
/* C99 does not define union cast, it is a GCC extension. */
+/* lint1-flags: -Sw */
+
struct bar {
int a;
int b;
@@ -14,9 +16,11 @@
};
void
-foo(void)
+foo(struct bar *a)
{
- struct bar *a; /* expect: 192 */
-
- ((union foo)a).a;
+ /* TODO: warn about union casts in general */
+ a = ((union foo)a).a;
+ /* expect+1: error: type 'pointer to char' is not a member of 'union foo' [329] */
+ a = ((union foo)"string");
+ a->a++;
}
diff -r 1cee7fc75bdc -r fe719f0fefc9 tests/usr.bin/xlint/lint1/d_c99_union_cast.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp Tue Aug 03 20:34:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp Tue Aug 03 20:46:10 2021 +0000
@@ -1,1 +1,1 @@
-d_c99_union_cast.c(19): warning: 'a' unused in function 'foo' [192]
+d_c99_union_cast.c(24): error: type 'pointer to char' is not a member of 'union foo' [329]
Home |
Main Index |
Thread Index |
Old Index