Re: GPC source code errors
Waldek Hebisch <[email protected]> Wed, 9 Mar 2016 15:33:37 +0100 (CET)
| Newsgroups | gmane.comp.compilers.gpc |
|---|---|
| Message-ID | <[email protected]> |
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)))
--
Waldek Hebisch
_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc