GPC source code errors

Gale Paeper gpaeper at
Thu Feb 25 07:09:17 CET 2016

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 (<>) 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);
  CHK_EM (source);
  CHK_EM (target);

I’m not sure how long the code “error” has been around.  I checked the gpc-20070904 sources and it is also in that version.

I don’t have a working GPC at the moment so I don’t know what sort of ill formed Pascal source code would be needed to exercise the CHK_EM macro return statement’s code and what sort of ills would result if the code was exercised.  

The compiler version information on the compiler being used for the compiling stopping errors is:

gcc --version
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix

Note: Apple has got their tool chain wired up so that “gcc” invokes LLVM based clang.

In case you want to see it I’ve included the gcc [really clang] and make diagnostic output below my signature.

P.S.  I think I’m getting close to seeing the light at the end of the tunnel of building a gcc-3.4.6 based GPC on the latest version of Mac OS X.  The path to success looks to be using a real gnu based gcc and as for compiling and assembling to object code.  At least for the fairly old code base of gcc-3.4.6, trying to use a LLVM based tool chain build path seems to be a never ending series of “close but no cigar” dead ends, issues, and headaches.	

Gale Paeper
gpaeper at

gcc -std=gnu99 -arch i386 -o p/statements.o -c   -g  -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes     -DHAVE_CONFIG_H    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes    -pedantic -Wno-long-long -Wno-traditional -I. -Ip -I../../gcc-3.4.6/gcc -I../../gcc-3.4.6/gcc/p -I../../gcc-3.4.6/gcc/../include  -DGPC -DGPC_UNITS_DIR=\"/usr/local/gpc346u4/gpc346u4/lib/gcc/i386-apple-darwin15/3.4.6/units\" -I../../gcc-3.4.6/gcc/p -DRTS_VERSION_CHECK="\"_p_GPC_RTS_VERSION_`cat ../../gcc-3.4.6/gcc/p/rts/rts-version`\"" ../../gcc-3.4.6/gcc/p/statements.c
4 warnings generated.
warning: unknown warning option '-Wno-traditional' [-Wunknown-warning-option]
In file included from ../../gcc-3.4.6/gcc/p/statements.c:29:
In file included from ../../gcc-3.4.6/gcc/p/gpc.h:46:
In file included from ../../gcc-3.4.6/gcc/p/gbe.h:151:
../../gcc-3.4.6/gcc/output.h:122:6: warning: '__format__' attribute argument not supported: asm_fprintf [-Wignored-attributes]
../../gcc-3.4.6/gcc/output.h:112:53: note: expanded from macro 'ATTRIBUTE_ASM_FPRINTF'
#define ATTRIBUTE_ASM_FPRINTF(m, n) __attribute__ ((__format__ (__asm_fprintf__, m, n))) ATTRIBUTE_NONNULL(m)
../../gcc-3.4.6/gcc/p/statements.c:1235:3: error: void function 'expand_pascal_assignment2' should not return a value [-Wreturn-type]
  CHK_EM (source);
../../gcc-3.4.6/gcc/p/gpc.h:155:36: note: expanded from macro 'CHK_EM'
#define CHK_EM(t) do { if (EM (t)) return error_mark_node; } while (0)
                                   ^      ~~~~~~~~~~~~~~~
../../gcc-3.4.6/gcc/p/statements.c:1236:3: error: void function 'expand_pascal_assignment2' should not return a value [-Wreturn-type]
  CHK_EM (target);
../../gcc-3.4.6/gcc/p/gpc.h:155:36: note: expanded from macro 'CHK_EM'
#define CHK_EM(t) do { if (EM (t)) return error_mark_node; } while (0)
                                   ^      ~~~~~~~~~~~~~~~
../../gcc-3.4.6/gcc/p/statements.c:1342:1: warning: no previous prototype for function 'assign_string2' [-Wmissing-prototypes]
assign_string2 (tree target, tree source, int is_init)
../../gcc-3.4.6/gcc/p/statements.c:1342:47: warning: unused parameter 'is_init' [-Wunused-parameter]
assign_string2 (tree target, tree source, int is_init)
4 warnings and 2 errors generated.
make[2]: *** [p/statements.o] Error 1
make[1]: *** [stage1_build] Error 2
make: *** [bootstrap] Error 2

More information about the Gpc mailing list