shithub: scc

Download patch

ref: 68f57d8dbb5cb1eebf38690d7330ac0f050b8bcd
parent: 8520ba859462224688f0afc7d3495afa7e44a5b2
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Oct 7 18:08:12 EDT 2013

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.

--- a/decl.c
+++ b/decl.c
@@ -114,10 +114,8 @@
 		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 @@
 		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");
 			}
--- a/symbol.h
+++ b/symbol.h
@@ -59,6 +59,10 @@
 	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);