yin parser BUGFIX bit statement appearance check
bit statement used to define possible bit values for bits type can
appear only (and MUST appear) when the type from which it is derived
is built-in bits type. When the type is derived from bits built-in
types in more steps, bit statement is prohibited.
diff --git a/src/parser/yin.c b/src/parser/yin.c
index 85c5c67..9dde769 100644
--- a/src/parser/yin.c
+++ b/src/parser/yin.c
@@ -925,14 +925,16 @@
goto error;
}
}
- if (!type->info.bits.count) {
- if (type->der->type.der) {
- /* this is just a derived type with no bit specified/required */
- break;
- }
+ if (!type->der->type.der && !type->info.bits.count) {
+ /* type is derived directly from buit-in bits type and bit statement is required */
LOGVAL(VE_MISSSTMT2, LOGLINE(yin), "bit", "type");
goto error;
}
+ if (type->der->type.der && type->info.bits.count) {
+ /* type is not directly derived from buit-in bits type and bit statement is prohibited */
+ LOGVAL(VE_INSTMT, LOGLINE(yin), "bit");
+ goto error;
+ }
type->info.bits.bit = calloc(type->info.bits.count, sizeof *type->info.bits.bit);
p = 0;