handle intorcard_type better in case statements
This commit is contained in:
parent
73ac23824b
commit
5252b760d9
4 changed files with 26 additions and 6 deletions
|
@ -832,13 +832,11 @@ ChkBinOper(expp)
|
||||||
tpl = BaseType(expp->nd_left->nd_type);
|
tpl = BaseType(expp->nd_left->nd_type);
|
||||||
tpr = BaseType(expp->nd_right->nd_type);
|
tpr = BaseType(expp->nd_right->nd_type);
|
||||||
|
|
||||||
if (tpl == intorcard_type) {
|
if (intorcard(tpl, tpr) != 0) {
|
||||||
if (tpr == int_type || tpr == card_type) {
|
if (tpl == intorcard_type) {
|
||||||
expp->nd_left->nd_type = tpl = tpr;
|
expp->nd_left->nd_type = tpl = tpr;
|
||||||
}
|
}
|
||||||
}
|
if (tpr == intorcard_type) {
|
||||||
if (tpr == intorcard_type) {
|
|
||||||
if (tpl == int_type || tpl == card_type) {
|
|
||||||
expp->nd_right->nd_type = tpr = tpl;
|
expp->nd_right->nd_type = tpr = tpl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,7 +400,11 @@ CaseLabels(t_type **ptp; register t_node **pnd;)
|
||||||
}:
|
}:
|
||||||
ConstExpression(pnd)
|
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 = *pnd;
|
||||||
nd->nd_type = BaseType(nd->nd_type); /* ??? */
|
nd->nd_type = BaseType(nd->nd_type); /* ??? */
|
||||||
|
|
|
@ -187,6 +187,7 @@ extern t_type
|
||||||
*proc_type(),
|
*proc_type(),
|
||||||
*enum_type(),
|
*enum_type(),
|
||||||
*qualified_type(),
|
*qualified_type(),
|
||||||
|
*intorcard(),
|
||||||
*RemoveEqual(); /* All from type.c */
|
*RemoveEqual(); /* All from type.c */
|
||||||
|
|
||||||
#define NULLTYPE ((t_type *) 0)
|
#define NULLTYPE ((t_type *) 0)
|
||||||
|
|
|
@ -795,6 +795,23 @@ lcm(m, n)
|
||||||
return m * (n / gcd(m, n));
|
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
|
#ifdef DEBUG
|
||||||
DumpType(tp)
|
DumpType(tp)
|
||||||
register t_type *tp;
|
register t_type *tp;
|
||||||
|
|
Loading…
Add table
Reference in a new issue