Skip to content

Commit

Permalink
Add a check for 'continue' inside a 'do ... while (0)' loop.
Browse files Browse the repository at this point in the history
'continue' has the same effect as 'break' - as that probably isn't
what the writer had in mind!
  • Loading branch information
dsl authored and dsl committed Jul 25, 2008
1 parent 3bccc0f commit d4d6980
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions usr.bin/xlint/lint1/err.c
@@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.36 2008/04/27 01:45:04 christos Exp $ */
/* $NetBSD: err.c,v 1.37 2008/07/25 18:33:53 dsl Exp $ */

/*
* Copyright (c) 1994, 1995 Jochen Pohl
Expand Down Expand Up @@ -37,7 +37,7 @@

#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: err.c,v 1.36 2008/04/27 01:45:04 christos Exp $");
__RCSID("$NetBSD: err.c,v 1.37 2008/07/25 18:33:53 dsl Exp $");
#endif

#include <sys/types.h>
Expand Down Expand Up @@ -382,6 +382,7 @@ const char *msgs[] = {
"({ }) is a GCC extension", /* 320 */
"array initializer with designators is a C9X feature", /* 321 */
"zero sized array is a C99 extension", /* 322 */
"continue in 'do ... while (0)' loop", /* 323 */
};

/*
Expand Down
6 changes: 4 additions & 2 deletions usr.bin/xlint/lint1/func.c
@@ -1,4 +1,4 @@
/* $NetBSD: func.c,v 1.22 2005/09/24 15:30:35 perry Exp $ */
/* $NetBSD: func.c,v 1.23 2008/07/25 18:33:53 dsl Exp $ */

/*
* Copyright (c) 1994, 1995 Jochen Pohl
Expand Down Expand Up @@ -37,7 +37,7 @@

#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: func.c,v 1.22 2005/09/24 15:30:35 perry Exp $");
__RCSID("$NetBSD: func.c,v 1.23 2008/07/25 18:33:53 dsl Exp $");
#endif

#include <stdlib.h>
Expand Down Expand Up @@ -774,6 +774,8 @@ do2(tnode_t *tn)
} else {
cstk->c_infinite = tn->tn_val->v_ldbl != 0.0;
}
if (!cstk->c_infinite && cstk->c_cont)
error(323);
}

expr(tn, 0, 1, 1);
Expand Down

0 comments on commit d4d6980

Please sign in to comment.