[PATCH 11/12] enum: warn on bad enums

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During the parsing of enum definitions, if some invalid
type combination is reached, the base type is forced to
'bad_ctype'. Good.

However, this is done without a warning and it's only when
the enum is used that some sign of a problem may appear,
with no hint toward the true cause.

Fix this by issuing a warning when the base type becomes invalid.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/parse.c b/parse.c
index 3bccc6023..41d5fd93a 100644
--- a/parse.c
+++ b/parse.c
@@ -925,8 +925,10 @@ static struct token *parse_enum_declaration(struct token *token, struct symbol *
 				info(expr->pos, "   expected: %s", show_typename(base_type));
 				info(expr->pos, "        got: %s", show_typename(ctype));
 				base_type = &bad_ctype;
-			} else
+			} else if (base_type != &bad_ctype) {
+				sparse_error(token->pos, "bad enum definition");
 				base_type = &bad_ctype;
+			}
 			parent->ctype.base_type = base_type;
 		}
 		if (is_int_type(base_type)) {
-- 
2.18.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux