Adriaan van Os wrote:
An Internal compiler error has been reported on the macpascal mailing list, as reproduced by the following program:
[G5:gcc/p/test] adriaan% cat avo10.pas program avo10; type UInt16 = cardinal attribute( size = 16); StyleItemGPC = (bold,italic,underline,outline,shadow,condense,extend); StyleParameter = UInt16; procedure TextFace(face: StyleParameter); external name 'TextFace'; begin TextFace( [bold, italic]); {internal compiler error} end.
[G5:gcc/p/test] adriaan% gpc avo10.pas ../../gcc-3.4.3/gcc/p/typecheck.c:123:incomplete_type_error: failed assertion `0' avo10.pas: In main program: avo10.pas:8: error: Internal compiler error. Please submit a full bug report to the GPC mailing list gpc@gnu.de. See URL:http://www.gnu-pascal.de/todo.html for details.
That one looks easy to correct: we just need proper error message (patch below).
G5:gcc/p/test] adriaan% gpc -v Reading specs from /Developer/Pascal/gpc343d7/lib/gcc/powerpc-apple-darwin7/3.4.3/specs Configured with: ../gcc-3.4.3/configure --enable-languages=pascal,c --enable-threads=posix --prefix=/Developer/Pascal/gpc343d7 --target=powerpc-apple-darwin7 --host=powerpc-apple-darwin7 Thread model: posix gpc version 20050217, based on gcc-3.4.3
Adding a typecast triggers another error:
G5:gcc/p/test] adriaan% cat avo11.pas program avo11; type UInt16 = cardinal attribute( size = 16); StyleItemGPC = (bold,italic,underline,outline,shadow,condense,extend); StyleParameter = UInt16; procedure TextFace(face: StyleParameter); external name 'TextFace'; begin TextFace( StyleParameter( [bold, italic])); {internal compiler error} end.
I am not sure if we should accept this program -- set constants in Pascal are really typeless, and their type is determined by the context. This cast gives no such context. The patch below tries to do something sensible...
--- p/typecheck.c.bb 2005-02-28 13:40:33.768665488 +0100 +++ p/typecheck.c 2005-02-28 13:40:55.883303552 +0100 @@ -119,6 +119,8 @@ error ("invalid use of array with unspecified bounds"); else if (TREE_CODE (type) == LANG_TYPE) error ("invalid use of forward declared type"); + else if (TREE_CODE (type) == SET_TYPE) + error ("invalid use of set type"); else assert (0); } --- p/expressions.c.bb 2005-02-22 19:03:40.000000000 +0100 +++ p/expressions.c 2005-02-28 14:37:28.252585032 +0100 @@ -3155,6 +3155,18 @@ else { /* Variable type cast. Convert a pointer internally. */ + /* Convert a set */ + if (TREE_CODE (otype) == SET_TYPE && TYPE_SIZE (otype) == NULL_TREE) + { + tree elements; + assert (TREE_CODE (value) == CONSTRUCTOR); + elements = CONSTRUCTOR_ELTS (value); + if (elements) + value = construct_set (value, NULL_TREE, 1); + else + return build_type_cast (type, integer_zero_node); + otype = TREE_TYPE (value); + } if (TREE_CODE (otype) != VOID_TYPE && TREE_CODE (type) != VOID_TYPE && !tree_int_cst_equal (TYPE_SIZE (otype), TYPE_SIZE (type)))