--- p/types.c.orig 2006-02-15 03:03:43.000000000 +0100 +++ p/types.c 2006-02-28 00:49:35.000000000 +0100 @@ -1558,6 +1558,9 @@ val1 = val2; val2 = tmp; } + + if (why != NOP_EXPR && MAX (TYPE_PRECISION (TREE_TYPE (val1)), TYPE_PRECISION (TREE_TYPE (val2))) < TYPE_PRECISION (pascal_integer_type_node)) + return pascal_integer_type_node; if (TREE_CODE (val1) == INTEGER_CST && TREE_CODE (TREE_TYPE (val2)) == INTEGER_TYPE && TYPE_MIN_VALUE (TREE_TYPE (val2)) @@ -1566,7 +1569,8 @@ && TREE_CODE (TYPE_MAX_VALUE (TREE_TYPE (val2))) == INTEGER_CST && !const_lt (val1, TYPE_MIN_VALUE (TREE_TYPE (val2))) && !const_lt (TYPE_MAX_VALUE (TREE_TYPE (val2)), val1)) - return TREE_TYPE (val2); + return (why != NOP_EXPR && TYPE_PRECISION (TREE_TYPE (val2)) < TYPE_PRECISION (pascal_integer_type_node)) + ? pascal_integer_type_node : TYPE_MAIN_VARIANT (TREE_TYPE (val2)); return common_type (TREE_TYPE (val1), TREE_TYPE (val2)); } --- /dev/null Thu Jan 1 01:00:00 1970 +++ p/test/avo13.pas Tue Feb 28 00:43:23 2006 @@ -0,0 +1,19 @@ +program testsubrange; + +type + int16 = integer attribute( size = 16); + int32 = integer attribute( size = 32); + point = record x,y: array [1 .. 8] of Byte end; {takes 16 bytes} + +var + i: int16; + +procedure P( size: int32); +begin + if size = 58528 then WriteLn ('OK') else WriteLn ('failed: ', 'size = ', size) +end; + +begin + i:= 3658; + P( i * SizeOf( point)); +end. --- /dev/null Thu Jan 1 01:00:00 1970 +++ p/test/ernst1.pas Tue Feb 28 00:42:07 2006 @@ -0,0 +1,17 @@ +PROGRAM testsubrange; +var + i: ShortInt; {signed 16 bit integer} + j: SizeType; {unsigned 32 bit word} + point : record x,y: array [1 .. 8] of Byte end; {takes 16 bytes} +begin + i:= 3658; + j:= 16; + if (i * j = 58528) and (i * SizeOf(point) = 58528) then + writeln ('OK') + else + begin + writeln ('failed:'); + writeln ('result1 = ', i*j); {58528, OK} + writeln ('result2 = ', i*SizeOf(point)); {-7008, wrong} + end +end. --- /dev/null Thu Jan 1 01:00:00 1970 +++ p/test/fjf1101.pas Tue Feb 28 00:33:33 2006 @@ -0,0 +1,8 @@ +program fjf1101 (Output); + +var + a, b: ShortInt value 1000; + +begin + if a * b = 1000000 then WriteLn ('OK') else WriteLn ('failed ', a * b) +end.