tpl = BaseType(expp->nd_left->nd_type);
tpr = BaseType(expp->nd_right->nd_type);
- if (tpl == intorcard_type) {
- if (tpr == int_type || tpr == card_type) {
+ if (intorcard(tpl, tpr) != 0) {
+ if (tpl == intorcard_type) {
expp->nd_left->nd_type = tpl = tpr;
}
- }
- if (tpr == intorcard_type) {
- if (tpl == int_type || tpl == card_type) {
+ if (tpr == intorcard_type) {
expp->nd_right->nd_type = tpr = tpl;
}
}
}:
ConstExpression(pnd)
{
- if (*ptp != 0 && ChkCompat(pnd, *ptp, "case label")) {
+ if (*ptp != 0) {
+ t_type *tp = intorcard(*ptp,
+ BaseType((*pnd)->nd_type), 0);
+ if (tp) *ptp = tp;
+ ChkCompat(pnd, *ptp, "case label");
}
nd = *pnd;
nd->nd_type = BaseType(nd->nd_type); /* ??? */
*proc_type(),
*enum_type(),
*qualified_type(),
+ *intorcard(),
*RemoveEqual(); /* All from type.c */
#define NULLTYPE ((t_type *) 0)
return m * (n / gcd(m, n));
}
+t_type *
+intorcard(left, right)
+ register t_type *left, *right;
+{
+ if (left == intorcard_type) {
+ if (right == int_type || right == card_type) {
+ return right;
+ }
+ }
+ else if (right == intorcard_type) {
+ if (left == int_type || left == card_type) {
+ return left;
+ }
+ }
+ return 0;
+}
+
#ifdef DEBUG
DumpType(tp)
register t_type *tp;