commit 68f57d8dbb5cb1eebf38690d7330ac0f050b8bcd
parent 8520ba859462224688f0afc7d3495afa7e44a5b2
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 7 Oct 2013 22:08:12 +0200
Add macros for storage and qualifier tests
These tests are used in different parts of the code, and they take
a lot of space, so it is a good option add two macros who can make
the code more readdable.
Diffstat:
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/decl.c b/decl.c
@@ -114,10 +114,8 @@ struct_dcl(unsigned char ns)
warn(options.implicit,
"data definition has no type or storage class");
}
- if (base->c_typedef || base->c_static || base->c_auto ||
- base->c_register || base->c_extern) {
+ if (HAS_STORAGE(base))
error("storage specifier in a struct/union field declaration");
- }
do {
declarator(base, ns);
@@ -351,8 +349,7 @@ repeat: if (!(tp = spec())) {
register unsigned char type = tp->type;
if (type == STRUCT || type == UNION || type == ENUM) {
- if (tp->c_extern || tp->c_static || tp->c_auto ||
- tp->c_register || tp->c_const || tp->c_volatile) {
+ if (HAS_STORAGE(tp) || HAS_QUALIF(tp)) {
warn(options.useless,
"useless storage class specifier in empty declaration");
}
diff --git a/symbol.h b/symbol.h
@@ -59,6 +59,10 @@ struct symbol {
struct symbol *hash;
};
+#define HAS_STORAGE(tp) ((tp)->c_extern || (tp)->c_static ||\
+ (tp)->c_auto || (tp)->c_register || (tp)->c_typedef)
+
+#define HAS_QUALIF(tp) ((tp)->c_const || (tp)->c_volatile)
extern struct ctype *decl_type(struct ctype *t);
extern void pushtype(unsigned mod);