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: combine duplicate case branches in...



details:   https://anonhg.NetBSD.org/src/rev/163d5d333a2b
branches:  trunk
changeset: 979567:163d5d333a2b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 01 14:11:20 2021 +0000

description:
lint: combine duplicate case branches in popdecl

This works around GCC 9, which didn't see that the following statement
cannot terminate normally, even though 0 is obviously a constant expression
and assert_failed is marked as __attribute__((__noreturn__)).

        do {
                if (!(0))
                        assert_failed(...);
        } while (0)

diffstat:

 usr.bin/xlint/lint1/decl.c |  12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diffs (40 lines):

diff -r 0bd8143e01af -r 163d5d333a2b usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Jan 01 14:08:33 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Jan 01 14:11:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.96 2021/01/01 13:43:34 kre Exp $ */
+/* $NetBSD: decl.c,v 1.97 2021/01/01 14:11:20 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.96 2021/01/01 13:43:34 kre Exp $");
+__RCSID("$NetBSD: decl.c,v 1.97 2021/01/01 14:11:20 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -612,11 +612,6 @@
        di = dcs;
        dcs = di->d_next;
        switch (di->d_ctx) {
-       case EXTERN:
-               /* there is nothing after external declarations */
-               lint_assert(0);
-               /* NOTREACHED */
-               /* XXX gcc is stupid enough not to know that, hence: */ break;
        case MOS:
        case MOU:
        case ENUMCON:
@@ -662,6 +657,9 @@
                /* usage of arguments will be checked by funcend() */
                rmsyms(di->d_dlsyms);
                break;
+       case EXTERN:
+               /* there is nothing after external declarations */
+               /* FALLTHROUGH */
        default:
                lint_assert(0);
        }



Home | Main Index | Thread Index | Old Index