@@ -70,6 +70,35 @@ struct format_state {
unsigned int used_position: 1;
};
+enum {
+ CLASS_OTHER,
+ CLASS_INT,
+ CLASS_BITWISE,
+ CLASS_FLOAT,
+ CLASS_PTR,
+};
+
+static inline int type_class(struct symbol *type, struct symbol **base)
+{
+ if (type->type == SYM_NODE)
+ type = type->ctype.base_type;
+ if (type->type == SYM_ENUM)
+ type = type->ctype.base_type;
+ *base = type;
+ if (type->type == SYM_BASETYPE) {
+ struct symbol *kind = type->ctype.base_type;
+ if (kind == &int_type)
+ return CLASS_INT;
+ if (kind == &fp_type)
+ return CLASS_FLOAT;
+ }
+ if (type->type == SYM_PTR)
+ return CLASS_PTR;
+ if (type->type == SYM_RESTRICT)
+ return CLASS_BITWISE;
+ return CLASS_OTHER;
+}
+
static int printf_fmt_numtype(struct format_type *fmt,
struct expression **expr,
struct symbol *ctype,
This will help the next patch to verify the types. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- verify-format.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)