Module Name: src Committed By: christos Date: Thu Nov 20 21:17:18 UTC 2014
Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: allow c99 flexible arrays for packed structures. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.76 src/usr.bin/xlint/lint1/tree.c:1.77 --- src/usr.bin/xlint/lint1/tree.c:1.76 Thu Apr 17 14:23:18 2014 +++ src/usr.bin/xlint/lint1/tree.c Thu Nov 20 16:17:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.76 2014/04/17 18:23:18 christos Exp $ */ +/* $NetBSD: tree.c,v 1.77 2014/11/20 21:17:18 christos Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.76 2014/04/17 18:23:18 christos Exp $"); +__RCSID("$NetBSD: tree.c,v 1.77 2014/11/20 21:17:18 christos Exp $"); #endif #include <stdlib.h> @@ -2998,17 +2998,21 @@ bldszof(type_t *tp) int64_t tsize(type_t *tp) { - int elem, elsz; + int elem, elsz, flex; elem = 1; + flex = 0; while (tp->t_tspec == ARRAY) { + flex = 1; /* allow c99 flex arrays [] [0] */ elem *= tp->t_dim; tp = tp->t_subt; } if (elem == 0) { - /* cannot take size of incomplete type */ - error(143); - elem = 1; + if (!flex) { + /* cannot take size of incomplete type */ + error(143); + elem = 1; + } } switch (tp->t_tspec) { case FUNC: