zertovitch / hac

HAC Ada Compiler - a small, quick Ada compiler fully in Ada
http://hacadacompiler.sf.net/
122 stars 11 forks source link

Compiler warnings with GCC 14.0.0 #15

Closed simonjwright closed 1 year ago

simonjwright commented 1 year ago

This is on macOS aarch64-apple-darwin, with GCC 14.0.0 20230820 (experimental):

hac_sys-defs.ads:453:59: warning: null range [enabled by default]

hac_sys-pcode-interpreter-operators.adb:232:05: warning: "Interfaces.Integer_64" is already use-visible through previous use_type_clause at s-arit64.ads:57 [-gnatwr]

Using gnat-llvm, built from the same compiler sources, these additional warnings are given:

hac_sys-interfacing.adb:107:05: warning: types for unchecked conversion have different sizes [-gnatwz]
hac_sys-interfacing.adb:107:05: warning: size of "Exported_Procedure" is 128, size of "Address" is 64 [-gnatwz]
hac_sys-interfacing.adb:107:05: warning: 64 trailing bits of source will be ignored [-gnatwz]

hac_sys-pcode-interpreter-calls.adb:104:07: warning: types for unchecked conversion have different sizes [-gnatwz]
hac_sys-pcode-interpreter-calls.adb:104:07: warning: size of "Address" is 64, size of "Exported_Procedure" is 128 [-gnatwz]
hac_sys-pcode-interpreter-calls.adb:104:07: warning: 64 trailing bits of target value will be undefined [-gnatwz]

which have to be the result of different code generation. Will try to cook up a small demonstrator for Adacore.

simonjwright commented 1 year ago

Well, in spite of those dire warnings, the demo/ examples ran fine.

You could decorate type Exported_Procedure with with Size => Standard’Address_Size, but that looks quite GNAT-specific.

My attempt to concoct a demonstrator failed, even with your GPR and all the compilation switches!

zertovitch commented 1 year ago

Thanks for the test! Regarding the first GNAT warning, it is legitimate: the range is actually empty.

  subtype Compile_Warning is Compile_Diagnostic
    range Compile_Diagnostic'Succ (err_obsolete_hat_name) .. err_obsolete_hat_name;
    --  ^ Fake, just, currently, an empty range!

This will heal with the appearance of the first kind of HAC warning (funny linguistic situation BTW: warnings about warnings). The second one is a GNAT bug, spotted on Zip-Ada as well. The third batch could be solved Address_To_Access conversions (I think there is a standard Ada.* package for that).

zertovitch commented 1 year ago

Regarding the Address issue (be it on GNAT's side or not), I have replaced the use of System.Address by an access : https://github.com/zertovitch/hac/commit/18ada18ab84a7e559a4eef3acddff454b7717169 . Does it prevent the warnings?

simonjwright commented 1 year ago

Does it prevent the warnings?

Yes, and the demo/ examples run OK.

zertovitch commented 1 year ago

Now with the appearance of the first HAC warning kind, the last GNAT 14.0.0 warning is the GNAT bug mentioned above.