add a check for negate cases on enumerations

Not supported by code so trigger an error to avoid invalid usages

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-05-16 16:55:02 +01:00
parent 1d47225a8e
commit c5a61aaa30

View File

@ -686,6 +686,7 @@ class SwitchCase:
if v == None:
return "1"
elif var_type.is_enum():
assert v[0] == "", "Negation of enumeration in switch is not supported"
checks.append("%s == %s" % (var_cname, var_type.c_enumname_by_name(v[1])))
else:
checks.append("%s(%s & %s)" % (v[0], var_cname, var_type.c_enumname_by_name(v[1])))