fix problem with variant tag and made double compatible with subranges
This commit is contained in:
parent
109a357e95
commit
e2bc68a46b
|
@ -641,11 +641,9 @@ VariantPart(struct scope *scope; arith *cnt; int *palign;
|
||||||
/* ISO 6.4.3.3 (p. 100)
|
/* ISO 6.4.3.3 (p. 100)
|
||||||
* The standard permits the integertype as tagtype, but demands that the set
|
* The standard permits the integertype as tagtype, but demands that the set
|
||||||
* of values denoted by the case-constants is equal to the set of values
|
* of values denoted by the case-constants is equal to the set of values
|
||||||
* specified by the tagtype. So we've decided not to allow integer as tagtype,
|
* specified by the tagtype.
|
||||||
* because it's not practical to enumerate ALL integers as case-constants.
|
|
||||||
* Though it wouldn't make a great difference to allow it as tagtype.
|
|
||||||
*/
|
*/
|
||||||
if( !(tp->tp_fund & T_INDEX) ) {
|
if( !(tp->tp_fund & T_INDEX)) {
|
||||||
error("illegal type in variant");
|
error("illegal type in variant");
|
||||||
tp = error_type;
|
tp = error_type;
|
||||||
}
|
}
|
||||||
|
@ -654,16 +652,21 @@ VariantPart(struct scope *scope; arith *cnt; int *palign;
|
||||||
|
|
||||||
getbounds(tp, &lb, &ub);
|
getbounds(tp, &lb, &ub);
|
||||||
ncst = ub - lb + 1;
|
ncst = ub - lb + 1;
|
||||||
|
if (ncst < 0 || ncst > (~(1L<<(8*sizeof(arith)-1)))/sizeof(struct selector *)) {
|
||||||
|
error("range of variant tag too wide");
|
||||||
|
tp = error_type;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* initialize selector */
|
||||||
|
(*sel)->sel_ptrs = (struct selector **)
|
||||||
|
Malloc((unsigned)ncst * sizeof(struct selector *));
|
||||||
|
(*sel)->sel_ncst = ncst;
|
||||||
|
(*sel)->sel_lb = lb;
|
||||||
|
|
||||||
/* initialize selector */
|
/* initialize tagvalue-table */
|
||||||
(*sel)->sel_ptrs = (struct selector **)
|
sp = (*sel)->sel_ptrs;
|
||||||
Malloc((unsigned)ncst * sizeof(struct selector *));
|
while( ncst-- ) *sp++ = *sel;
|
||||||
(*sel)->sel_ncst = ncst;
|
}
|
||||||
(*sel)->sel_lb = lb;
|
|
||||||
|
|
||||||
/* initialize tagvalue-table */
|
|
||||||
sp = (*sel)->sel_ptrs;
|
|
||||||
while( ncst-- ) *sp++ = *sel;
|
|
||||||
}
|
}
|
||||||
(*sel)->sel_type = tp;
|
(*sel)->sel_type = tp;
|
||||||
if( df ) {
|
if( df ) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ TstCompat(tp1, tp2)
|
||||||
/* no clause, just check for longs and ints */
|
/* no clause, just check for longs and ints */
|
||||||
/* BaseType is used in case of array indexing */
|
/* BaseType is used in case of array indexing */
|
||||||
if ((BaseType(tp1) == int_type && tp2 == long_type) ||
|
if ((BaseType(tp1) == int_type && tp2 == long_type) ||
|
||||||
(tp1 == long_type && tp2 == int_type))
|
(tp1 == long_type && BaseType(tp2) == int_type))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue