Gale Paeper wrote:
While trying to get a successful compilation of GPC on Mac OS X 10.11 using AppleâÂÂs LLVM based tool chain, I discovered what looks to be a couple of source code errors in p/statements.c in the expand_pascal_assignment2 functionâÂÂs code. That function is declared with a void return type so there shouldnâÂÂt be any return statements returning a value anywhere within the body of the function but there are two uses of the CHK_EM macro which does expand to a return statement that potentially returns a value (a tree type). Trying to potentially return something into the void of a non-existant return isnâÂÂt technically correct code and I havenâÂÂt found a way to get the LLVM based clang compiler to accept it.
IâÂÂll note that you can get a gnu gcc version 5.2.0 compiler to accept the code when compiling with the -std=gnu89 command line option.
The GPC source code version IâÂÂm trying to get compiling is the Adriaan van OsâÂÂs Mac OS X patched gcc 3.4.6 with the p directory replaced with Waldek HebischâÂÂs git repositoryâÂÂs (https://github.com/hebisch/gpc) p directory source code. The code fragment containing the error producing code starting around line 1231 in file p/statements.c (in expand_pascal_assignment2 functionâÂÂs body) is:
schema_source = undo_schema_dereference (source); schema_target = undo_schema_dereference (target); DEREFERENCE_SCHEMA (source); DEREFERENCE_SCHEMA (target); CHK_EM (source); CHK_EM (target);
The patch below should fix this:
diff --git a/p/statements.c b/p/statements.c index 4904834..e0026b7 100644 --- a/p/statements.c +++ b/p/statements.c @@ -1232,8 +1232,8 @@ expand_pascal_assignment2 (tree target, tree source, int is_init) schema_target = undo_schema_dereference (target); DEREFERENCE_SCHEMA (source); DEREFERENCE_SCHEMA (target); - CHK_EM (source); - CHK_EM (target); + if (EM (source)||EM (target)) + return;
/* Restricted types. @@@@ Maybe this needs further checking */ if (TREE_CODE (source) == CALL_EXPR && PASCAL_TYPE_RESTRICTED (TREE_TYPE (source)))