Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: in strict enum mode, error out on ...
details: https://anonhg.NetBSD.org/src/rev/6afd9d817475
branches: trunk
changeset: 1022736:6afd9d817475
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Aug 03 21:18:24 2021 +0000
description:
lint: in strict enum mode, error out on enum type mismatch in union cast
diffstat:
tests/usr.bin/xlint/lint1/gcc_cast_union.c | 4 ++--
tests/usr.bin/xlint/lint1/gcc_cast_union.exp | 1 +
usr.bin/xlint/lint1/decl.c | 7 +++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diffs (54 lines):
diff -r 4285f23986b2 -r 6afd9d817475 tests/usr.bin/xlint/lint1/gcc_cast_union.c
--- a/tests/usr.bin/xlint/lint1/gcc_cast_union.c Tue Aug 03 21:09:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_cast_union.c Tue Aug 03 21:18:24 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc_cast_union.c,v 1.2 2021/08/03 21:09:26 rillig Exp $ */
+/* $NetBSD: gcc_cast_union.c,v 1.3 2021/08/03 21:18:24 rillig Exp $ */
# 3 "gcc_cast_union.c"
/*
@@ -81,7 +81,7 @@
any = (union anything)E1;
any = (union anything)E2;
/* GCC allows enum mismatch even with -Wenum-conversion */
- /* XXX: Lint should warn about enum type mismatch */
+ /* expect+1: error: type 'enum other_enum' is not a member of 'union anything' [329] */
any = (union anything)OTHER;
/* expect+1: error: type 'pointer to char' is not a member of 'union anything' [329] */
any = (union anything)"char *";
diff -r 4285f23986b2 -r 6afd9d817475 tests/usr.bin/xlint/lint1/gcc_cast_union.exp
--- a/tests/usr.bin/xlint/lint1/gcc_cast_union.exp Tue Aug 03 21:09:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_cast_union.exp Tue Aug 03 21:18:24 2021 +0000
@@ -1,3 +1,4 @@
+gcc_cast_union.c(85): error: type 'enum other_enum' is not a member of 'union anything' [329]
gcc_cast_union.c(87): error: type 'pointer to char' is not a member of 'union anything' [329]
gcc_cast_union.c(90): error: type 'pointer to double' is not a member of 'union anything' [329]
gcc_cast_union.c(92): error: type 'pointer to double' is not a member of 'union anything' [329]
diff -r 4285f23986b2 -r 6afd9d817475 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Tue Aug 03 21:09:26 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Tue Aug 03 21:18:24 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.218 2021/08/03 18:38:02 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.218 2021/08/03 18:38:02 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $");
#endif
#include <sys/param.h>
@@ -2225,6 +2225,9 @@
if (t == STRUCT || t == UNION)
return tp1->t_str == tp2->t_str;
+ if (t == ENUM && eflag)
+ return tp1->t_enum == tp2->t_enum;
+
if (t == ARRAY && tp1->t_dim != tp2->t_dim) {
if (tp1->t_dim != 0 && tp2->t_dim != 0)
return false;
Home |
Main Index |
Thread Index |
Old Index