+/*------------------------------------------------------------------
+ checkTypeSanity: prevent the user from doing e.g.:
+ unsigned float uf;
+ ------------------------------------------------------------------*/
+void checkTypeSanity(sym_link *dest) {
+ char *noun;
+ switch (SPEC_NOUN(dest))
+ {
+ case V_CHAR: noun="char"; break;
+ case V_INT: noun="int"; break;
+ case V_FLOAT: noun="float"; break;
+ case V_DOUBLE: noun="double"; break;
+ case V_VOID: noun="void"; break;
+ default: noun="unknown type"; break;
+ }
+
+ if ((SPEC_NOUN(dest)==V_CHAR ||
+ SPEC_NOUN(dest)==V_FLOAT ||
+ SPEC_NOUN(dest)==V_DOUBLE ||
+ SPEC_NOUN(dest)==V_VOID) &&
+ (SPEC_SHORT(dest) || SPEC_LONG(dest))) {
+ // long or short for char float double or void
+ werror (E_LONG_OR_SHORT_INVALID, noun, yylval.yychar);
+ }
+ if ((SPEC_NOUN(dest)==V_FLOAT ||
+ SPEC_NOUN(dest)==V_DOUBLE ||
+ SPEC_NOUN(dest)==V_VOID) &&
+ (SPEC_SIGNED(dest) || SPEC_USIGN(dest))) {
+ // signed or unsigned for float double or void
+ werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, yylval.yychar);
+ }
+ if (SPEC_SIGNED(dest) && SPEC_USIGN(dest)) {
+ // signed AND unsigned
+ werror (E_SIGNED_AND_UNSIGNED_INVALID, noun, yylval.yychar);
+ }
+ if (SPEC_SHORT(dest) && SPEC_LONG(dest)) {
+ // short AND long
+ werror (E_LONG_AND_SHORT_INVALID, noun, yylval.yychar);
+ }
+}
+