[PATCH 8/9] enum: warn on bad enums

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

 



During the parsing of enums definition, 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 will be used that some sign of a problem will appear.

Fix this by issuing a warnings when the base type is set to bad.

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 0b5524e5e..4e853d1b9 100644
--- a/parse.c
+++ b/parse.c
@@ -912,8 +912,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.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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