aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/parse.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-07 20:31:56 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-10-05 03:29:19 +0200
commitc7f7ccfcf1888965a0dcfccb4f4466ce22b3eeb9 (patch)
tree014c62b93524349e5adc844986d636737dadf599 /parse.c
parent56a8674803a512f846a059288f3524b2ee7a950f (diff)
downloadsparse-dev-c7f7ccfcf1888965a0dcfccb4f4466ce22b3eeb9.tar.gz
enum: warn when mixing different restricted types
Sparse supports enum initializers with bitwise types but this makes sense only if they are all the same type. Add a check and issue a warning if an enum is initialized with different restricted types. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index ac8c0aad..3bccc602 100644
--- a/parse.c
+++ b/parse.c
@@ -920,6 +920,11 @@ static struct token *parse_enum_declaration(struct token *token, struct symbol *
if (!mix_bitwise++) {
warning(expr->pos, "mixed bitwiseness");
}
+ } else if (is_restricted_type(base_type) && base_type != ctype) {
+ sparse_error(expr->pos, "incompatible restricted type");
+ info(expr->pos, " expected: %s", show_typename(base_type));
+ info(expr->pos, " got: %s", show_typename(ctype));
+ base_type = &bad_ctype;
} else
base_type = &bad_ctype;
parent->ctype.base_type = base_type;