GPC BUG: Enum type not accepted as conformant array bounds
Hello, I found the following bug in the Beta version of GPC. Best regards, Peter Dietrich -------------------- GPC-Version (gpc -v): Reading specs from C:\usr\local\lib\gcc-lib\i386-mingw32\2.8.1\specs gpc version 19990118, based on gcc-2.8.1 System-Version: Windows NT 4.0 on i386 Problem description: GPC does not accept conformant array bounds of enum types. The following program results in the compiler error message: test1.pas: In function `program_Test': test1.pas:13: incompatible type for argument 1 of `P' test1.pas:13: incompatible type for argument 2 of `P' program test (output); type t = (red,green,blue); procedure p (a : array[lb..ub:t] of char); begin end; var a : array[t] of char; begin p (a); end.
Hallo, Peter! pdietrich@synstar.de wrote:
GPC does not accept conformant array bounds of enum types.
Fixed (pd2.pas). Patch below. Peter -- Peter Gerwinski, Essen, Germany, http://home.pages.de/~Peter.Gerwinski/ Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-19990118 PGP key on request - 6C 94 45 BE 28 A4 96 - 0E CC E9 12 47 25 82 75 *** Vote against SPAM! ********* http://www.politik-digital.de/spam/ *** --- gpc-typeck.c.orig Sun Apr 11 00:20:50 1999 +++ gpc-typeck.c Thu Jun 17 01:23:30 1999 @@ -544,7 +544,7 @@ /* Enumeral types must match almost exactly. */ if (TREE_CODE (t1) == ENUMERAL_TYPE || TREE_CODE (t2) == ENUMERAL_TYPE) - return base_type (t1) == base_type (t2) ? 1 : 0; + return TYPE_VALUES (base_type (t1)) == TYPE_VALUES (base_type (t2)) ? 1 : 0; #else /* not GPC */ @@ -1762,7 +1762,7 @@ enum tree_code code0 = TREE_CODE (type0); enum tree_code code1 = TREE_CODE (type1); if (code0 == ENUMERAL_TYPE || code1 == ENUMERAL_TYPE) - return base_type (type0) == base_type (type1); + return comptypes (type0, type1); else return (code0 == code1) || (code0 == REAL_TYPE && code1 == INTEGER_TYPE) @@ -2743,6 +2743,8 @@ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */ if (TREE_CODE (val) == NON_LVALUE_EXPR) val = TREE_OPERAND (val, 0); + + val = convert (TYPE_DOMAIN (atype), val); } /* Used one index */
participants (2)
-
pdietrich@synstar.de -
Peter Gerwinski