This patch fixes many static scaffold bugs and contains
a re-implementation of UnixArgs.cc and termios.cc. gm2l
contains new options --exlude=, --include= and -flibs=.
2022-07-04 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/ChangeLog:
* doc/gm2.texi (-fscaffold-c): Removed. (-fscaffold-c++)
Removed. (-fmodules) Removed. (-fonlylink) Removed.
gcc/m2/ChangLog:
* Make-lang.in (UnixArgs.o): Use UnixArgs.cc.
(gm2-pge-boot/Gtermsios.o) Use mc-boot-ch/Gtermios.cc.
* bnf/gm2l.bnf: Partial re-write and introduced
--include=, --exclude= and -flibs=. (AddUserInclude)
New procedure. (ScanSources) Remove IncludeM2RTS
filter. (MakeModule) Return a boolean if a new module
is seen. (source) New field userInclude.
(source) New field userExclude. (DisplaySources)
test for userExclude and userInclude and produce
appropriate diagnostic. (DisplayUsage) Remove
--M2RTS. Add -flibs=, --include-list= and --exclude-list=.
(PopulateList) New procedure. (addInclude) New procedure.
(SetLibs) New procedure. (SetExclude) New procedure.
(ScanArgs) Remove IncludeM2RTS. Remove --M2RTS.
Add --include=, --exclude= and -flibs=. Detect if multiple
source files are given and detect any unrecognized option.
* bnf/gm2m.bnf (main): Renamed as mainModule.
* gm2-compiler/M2Options.mod (SetScaffoldDynamic): Ensure that
ScaffoldStatic is not also set. (SetScaffoldStatic) Ensure
that ScaffoldDynamic is not also set.
* gm2-compiler/M2Quads.mod (BuildM2FiniFunction):
Add ForeachModuleCallFinish for the static clause.
(BuildM2InitFunction) Add ForeachModuleCallInit for the
static clause.
* gm2-compiler/M2Scaffold.def (ForeachModuleCallInit):
New procedure. (ForeachModuleCallFinish) New Procedure.
* gm2-compiler/M2Scaffold.mod (ForeachModuleCallInit):
New procedure implemented. (ForeachModuleCallFinish) New
Procedure implemented. (LookupModuleSym) New procedure.
(ReadModules) Addition parameter tok and populate
uselistModules. (DeclareModuleExtern) Renamed from
DeclareCtorModuleExtern.
* gm2-compiler/M2Swig.mod (main): Renamed as mainModule.
* gm2-compiler/SymbolTable.def (PutModuleCtorExtern): Exported
and declared. (MakeModuleCtor) Pass extra boolean public true.
(InitCtorFields) pub new parameter. (PutProcedureExternPublic)
New procedure. (PutCtorExtern) New procedure.
(PutModuleCtorExtern) New procedure.
* gm2-gcc/init.cc: Rewritten to pass envp to call init and fini
functions.
* gm2-gcc/m2expr.def: FOR "C" removed.
* gm2-libs-ch/RTcodummy.c: Undo removal of _init and _finish
functions.
* gm2-libs-ch/pthdummy.c (Removed).
* m2/gm2spec.cc (seen_scaffold_static): New boolean.
(seen_scaffold_dynamic) New boolean. (scaffold_static)
New boolean. (scaffold_dynamic) New boolean.
(get_libexec) Removed. (add_exec_dir) Rewritten comment.
(lang_specific_driver) Check that dynamic scaffold and static
scaffold are not both enabled.
* mc-boot-ch/Gpth.c (Removed).
* mc-boot-ch/Gtermios.c (Removed).
* mc-boot-ch/Gtermios.cc (Added). Converted from Gtermios.c.
gm2tools/ChangeLog:
* gm2l.1 (--M2RTS) Removed. (-M2RTS) Removed. (--include=) Added.
(--exclude=) Added. (-flibs=) Added.
libgm2/ChangeLog:
* libm2iso/ErrnoCategory.cc (_finish): Changed to _fini.
* libm2iso/RTco.cc (_finish): Changed to _fini.
* libm2pim/SysExceptions.cc (_finish): Changed to _fini.
* libm2pim/errno.cc (_finish): Changed to _fini.
* libm2pim/termios.cc (_finish): Changed to _fini.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
This patch changes the tests in the testsuite which refer to UnixArgs.
2022-06-29 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/testsuite/gm2/ChangeLog:
* link/pimc/pass/testgetopt.mod: Replace ArgC with
call to GetArgC and replace ArgV with a call to GetArgV.
* link/pimc/pass/testunixargs.mod: Replace ArgC with
call to GetArgC and replace ArgV with a call to GetArgV.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-06-29 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/m2/ChangeLog:
* Make-lang.in (GM2-LIBS-BOOT-C): Remove UnixArgs.c,
dtoa.c and ldtoa.c. (GM2-LIBS-BOOT-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
(GM2-LIBS-C) Remove UnixArgs.c, dtoa.c and ldtoa.c.
(GM2-LIBS-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
(MC-INTERFACE-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
(PPG-INTERFACE-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
Adapted remaining rules to use above definitions
and added rules to build from .cc files.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
This patch also includes a mc-boot translated copy of the
module M2Dependent.
gcc/m2/ChangeLog:
* gm2-libs-ch/UnixArgs.cc: Renamed from gm2-libs-ch/UnixArgs.c.
* gm2-libs-ch/dtoa.cc: Renamed from gm2-libs-ch/dtoa.c.
* gm2-libs-ch/ldtoa.cc: Renamed from gm2-libs-ch/ldtoa.c.
* gm2-libs-ch/m2rts.h: New file.
* mc-boot-ch/GUnixArgs.cc: New file.
* mc-boot-ch/m2rts.h: New file.
* mc-boot/GM2Dependent.c: New file.
* mc-boot/GM2Dependent.h: New file.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
This patch moves more of the C support files in the modula-2 library
into C++ files with a dynamic scaffold signature. It also tidied
up the interface to UnixArgs and required a rebuild of the bootstrap
tool mc.
2022-06-29 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/m2/ChangeLog:
* bnf/gm2l.bnf (BlockInfoPtr): Capitalized comment starts.
* gm2-libs-ch/UnixArgs.cc: Rewritten from UnixArgs.c in C++
with ctor scaffold.
* gm2-libs-ch/dtoa.cc (M2_dtoa_init): Added correct argc,
argv, envp parameters. (M2_dtoa_finish) Added correct argc,
argv, envp parameters. (M2_dtoa_dep) New function.
(M2_dtoa_ctor) New function.
* gm2-libs-ch/ldtoa.cc (M2_ldtoa_init): Added correct argc,
argv, envp parameters. (M2_ldtoa_finish) Added correct argc,
argv, envp parameters. (M2_ldtoa_dep) New function.
(M2_ldtoa_ctor) New function.
* gm2-libs-iso/ProgramArgs.mod: Changed to use GetArgC and
GetArgV.
* gm2-libs/Args.def: Renamed parameter name from i to n.
* gm2-libs/Args.mod: Changed to use GetArgC and
GetArgV.
* gm2-libs/SArgs.def: Renamed parameter name from i to n.
* gm2-libs/SArgs.mod: Changed to use GetArgC and
GetArgV.
* gm2-libs/UnixArgs.def: Rewritten to export GetArgC, GetArgV
and GetEnvV.
* init/mcinit: Commented out M2Dependent.
* mc-boot-ch/GM2LINK.c: Include cstddef.h and declare
ForcedModuleInitOrder.
* mc-boot-ch/GUnixArgs.cc: Rewritten in C++ from GUnixArgs.c.
* mc-boot/GArgs.c: Rebuilt.
* mc-boot/GArgs.h: Rebuilt.
* mc-boot/GM2RTS.c: Rebuilt.
* mc-boot/GM2RTS.h: Rebuilt.
* mc-boot/GSArgs.c: Rebuilt.
* mc-boot/GSArgs.h: Rebuilt.
* mc-boot/GUnixArgs.h: Rebuilt.
* mc-boot/Gdecl.c: Rebuilt.
* mc/mc.flex: Rebuilt.
libgm2/ChangeLog:
* libm2pim/Makefile.am (libm2pim_la_SOURCES): UnixArgs.c
removed UnixArgs.cc added. (libm2pim_la_SOURCES) sckt.c
removed sckt.cc added. (libm2pim_la_SOURCES) dtoa.c
removed dtoa.cc added. (libm2pim_la_SOURCES) ldtoa.c
removed ldtoa.cc added. (libm2pim_la_SOURCES) Selective.c
removed Selective.cc added.
* libm2pim/UnixArgs.cc: Rewritten in C++.
* libm2pim/dtoa.cc: Rewritten in C++.
* libm2pim/ldtoa.cc: Rewritten in C++.
* libm2pim/sckt.cc: Rewritten in C++.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
This patch fixes (re-introduces) the -fcpp option and it
migrates more testsuite tcl files to use the new linking mechanism.
2022-06-26 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/m2/ChangeLog:
* bnf/gm2l.bnf (ScanArgs): -fcppbegin changed to -fcpp-begin.
* gm2-compiler/M2DriverOptions.mod (ScanCppArgs):
-fcppbegin changed to -fcpp-begin, -fcppend changed to
-fcpp-end.
* gm2-compiler/M2GenGCC.mod (CodeFinallyEnd): Check
we are compiling the main module before generating
the scaffold.
* gm2-compiler/M2Options.mod (CppRemember): -fcppbegin
changed to -fcpp-begin. (CppArg) -fcppbegin
changed to -fcpp-begin, -fcppend changed to -fcpp-end.
-fcppprog changed to -fcpp-prog.
* gm2-compiler/P2SymBuild.mod (BlockEnd): Added assert.
(PopBlock) bug fix, curModuleSym is popped in
correct sequence.
* gm2-lang.cc (gm2_langhook_init_options):
-fcppbegin changed to -fcpp-begin. -fcppend changed to
-fcpp-end. -fcppprog changed to -fcpp-prog.
* gm2spec.cc (get_libexec): New function.
(gen_gm2_libexec) New function. (add_exec_dir) New function.
(lang_register_spec_functions) add exec_prefix.
* lang-specs.h: -fcppbegin changed to -fcpp-begin.
-fcppend changed to -fcpp-end.
* lang.opt: Uniform internal switch statement used
where necessary. -fcppbegin changed to -fcpp-begin.
-fcppend changed to -fcpp-end. -fcppprog= changed to -fcpp-prog=.
libgm2/Changelog:
* libm2iso/m2rts.h: (New file).
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
This patch further cleans up the driver gm2. It also moves
some of the C support libraries into C++ mimicing m2 ctor
behaviour. -fuselist= is also implemented which forces
module ctors to be referenced in the scaffold.
2022-06-25 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/ChangeLog:
* doc/gm2.texi (-fobject-path=): Removed. (-fmakeinit)
Removed. (-fmakelist) Removed. (-fuselist) Removed.
(-fuselist=@file{filename}) Added.
gcc/m2/ChangeLog:
* m2/gm2-compiler/Lists.mod: Corrected spacing.
* m2/gm2-compiler/M2Options.def (SetUselist): New procedure.
(GetUselist) New procedure function.
* m2/gm2-compiler/M2Options.mod (UselistFilename): New
variable. (SetUselist) New procedure implementation.
(GetUselist) New procedure implementation.
* m2/gm2-compiler/M2Quads.mod (BuildM2LinkFunction)
New procedure. (BuildM2MainFunction) build call to
linkFunction. (BuildScaffold) call BuildM2MainFunction.
(MakeLengthConst) Re-implemented.
* m2/gm2-compiler/M2Scaffold.def (linkFunction):
New variable. (PopulateCtorArray) New procedure.
* m2/gm2-compiler/M2Scaffold.mod (DeclareCtorArrayType):
New procedure function. (DeclareCtorGlobal) New procedure.
(PopulateCtorArray) New procedure. (ReadModules) New
procedure. (CreateCtorList) New procedure function.
(DeclareCtorModuleExtern) New procedure.
(DeclareScaffoldFunctions) Declare the ctor global array and
declare all external modules ctors.
* m2/gm2-compiler/PCSymBuild.mod: Remove stop.
* m2/gm2-compiler/SymbolTable.def (MakeProcedureCtorExtern)
New procedure function. (PutExtern) New procedure function.
(IsExtern) New procedure function. (MakeConstant) New
procedure function.
* m2/gm2-compiler/SymbolTable.mod (Procedure): New field IsExtern.
(MakeProcedureCtorExtern) New procedure function.
(PutExtern) New procedure. (IsExtern) New procedure function.
(MakeConstant) New procedure function implemented.
* m2/gm2-gcc/m2options.h (SetUselist): New procedure.
* m2/gm2-lang.cc (fuselist): Removed. (fmakelist) Removed.
(fmodules) Removed. (fuselist_) Added.
* m2/gm2spec.cc (fuselist): Removed.
* m2/lang.opt (fuselist): Removed. (fmakelist) Removed.
(fmodules) Removed. (fuselist=) Added.
libgm2/Changelog:
* libm2pim/Makefile.am (M2MODS): Add M2Dependent.mod
(M2DEFS) Add M2Dependent.def.
* libm2iso/ErrnoCategory.cc (Renamed from ErrnoCategory.c).
Converted to C++.
* libm2iso/Makefile.am: Changed .c extensions to .cc.
* libm2iso/RTco.cc (Renamed from RTco.c): Converted to C++.
* libm2pim/Makefile.am: Changed .c extensions to .cc.
* libm2pim/SysExceptions.cc (Renamed from SysExceptions.c):
Converted to C++.
* libm2pim/errno.cc (Renamed from errno.c): Converted to C++.
* libm2pim/termios.cc (Renamed from termios.c): Converted to C++.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/m2/ChangeLog:
* gm2-compiler/M2Scaffold.def (New file).
* gm2-compiler/M2Scaffold.mod (New file).
* gm2-libs-ch/M2LINK.c (New file).
* gm2-libs/M2Dependent.def (New file).
* gm2-libs/M2Dependent.mod (New file).
* gm2-libs/M2LINK.def (New file).
* m2-link-support.h (Removed file).
* mc-boot-ch/GM2LINK.c (New file).
* mc-boot/GM2LINK.h (New file).
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
A large commit consisting of a re-implementing of the scaffold
generation for modula-2. The changes allow the compiler
to be built, installed and hello world can be compiled and linked.
The default scaffold generated by modula-2 is propagated to M2RTS
via ctors. At runtime M2RTS resolves the dependency import graph
and calls each module init/fini code.
2022-06-20 Gaius Mulley <gaius.mulley@southwales.ac.uk>
gcc/ChangeLog:
* doc/gm2.texi: Replaced English spelling to American.
(-fscaffold-static) New option documented. (-fscaffold-dynamic)
New option documented. (-fscaffold-c) New option documented.
(-fscaffold-c++) New option documented.
gcc/m2/ChangeLog:
* Make-lang.in (stage1/m2/cc1gm2$(exeext)): M2LINK.o added.
(GM2-LIBS-BOOT-MODS) M2Dependent.mod added. (GM2-COMP-BOOT-MODS)
M2Scaffold.mod added. (GM2-LIBS-DEFS) M2Dependent.def added.
(GM2-LIBS-MODS) added. (GM2-COMP-DEFS) M2Scaffold.def added.
(GM2-COMP-MODS) M2Scaffold.mod added.
(m2/gm2-libs-boot/M2LINK.o) New rule. (stage1/m2/gm2l$(exeext))
added M2LINK.o. (stage1/m2/gm2lcc$(exeext)) added M2LINK.o
(stage1/m2/gm2lcc$(exeext)) added M2LINK.o.
(stage1/m2/gm2lgen$(exeext)) added M2LINK.o.
(stage1/m2/gm2lgen$(exeext)) added M2Link.o.
(stage1/m2/gm2lorder$(exeext)) added M2Link.o.
(stage1/m2/gm2m$(exeext)) added M2Link.o.
(MC-LIB-DEFS) M2LINK.def added. (MC-INTERFACE-C)
M2LINK.c added. (PPG-LIB-DEFS) M2Dependent.def added.
(PPG-LIB-MODS) M2Dependent.mod added.
(m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) search m2/gm2-libs-boot.
(m2/ppg$(exeext)) added M2LINK.o.
(m2/gm2-pg-boot/$(SRC_PREFIX)%.o) added M2LINK.o.
(m2/gm2-pge-boot/$(SRC_PREFIX)%.o) added M2LINK.o.
* bnf/m2-1.bnf: Added production rules to record import
statements and module dependents.
* bnf/m2-2.bnf: Added production rules to record block
begin/end pairs.
* bnf/m2-3.bnf (ProgramModule): Call BuildScaffold.
(ImplementationModule) Call BuildScaffold.
* gm2-compiler/M2Base.mod: Reformatted.
* gm2-compiler/M2GCCDeclare.mod (DeclareProcedureToGcc):
Re-implemented. (DeclareModuleInit) re-implemented.
* gm2-compiler/M2GenGCC.mod (IsExportedGcc): Check IsPublic.
(CallInnerInit) get init function using GetModuleCtors
and build call to init. (CallInnerFinally) get fini
function using GetModuleCtors and build call to fini.
(CodeInitEnd) call GetModuleCtors and finish call to init.
(CodeFinallyStart) call GetModuleCtors and start function fini.
(CodeFinallyEnd) call GetModuleCtors and finish function fini.
Call DeclareM2linkGlobals to set the ScaffoldStatic and
ForcedModuleInitOrder variables in the main program.
(CodeKillLocalVar) test the procedure is a ctor if so call
DeclareModuleCtor and BuildModuleCtor.
(ConvertForComparison) Removed. (DetermineFieldOf) Removed.
* gm2-compiler/M2MetaError.mod: Added import of Storage.
* gm2-compiler/M2Options.def (ScaffoldDynamic): New procedure.
(ScaffoldStatic) New procedure. (SetScaffoldDynamic) New procedure.
(SetScaffoldStatic) New procedure. (SetScaffoldMain) New
procedure. (ScaffoldMain) New procedure.
(SetRuntimeModuleOverride) New procedure.
(GetRuntimeModuleOverride) New procedure.
* gm2-compiler/M2Options.mod: (ScaffoldDynamic): New procedure
implemented. (ScaffoldStatic) New procedure implemented.
(SetScaffoldDynamic) New procedure implemented.
(SetScaffoldStatic) New procedure implemented.
(SetScaffoldMain) New procedure implemented.
(ScaffoldMain) New procedure implemented.
(SetRuntimeModuleOverride) New procedure implemented.
(GetRuntimeModuleOverride) New procedure implemented.
* gm2-compiler/M2Quads.def (BuildScaffold) New procedure defined.
* gm2-compiler/M2Quads.mod (BuildScaffold) New procedure
implemented. (callRequestDependant) New procedure.
(ForeachImportedModuleDo) New procedure. (BuildM2DepFunction)
New procedure. (BuildM2MainFunction) New procedure.
(BuildM2InitFunction) New procedure. (BuildM2FiniFunction)
New procedure. (BuildM2CtorFunction) New procedure.
(BuildScaffold) New procedure. (GetQualidentImport) use %1a
rather than %Ea.
* gm2-compiler/P1SymBuild.def (BuildImportStatement): New
procedure definition. (AddImportToImportStatement) New
procedure definition.
* gm2-compiler/P1SymBuild.mod: (BuildImportStatement): New
procedure implementation. (AddImportToImportStatement) New
procedure implementation.
* gm2-compiler/P2SymBuild.def (BlockStart): New procedure
definition. (BlockEnd) New procedure definition.
(BlockBegin) New procedure definition. (BlockFinally)
New procedure definition.
* gm2-compiler/P2SymBuild.mod (BlockStart): New procedure
implementation. (BlockEnd) New procedure implementation.
(BlockBegin) New procedure implementation. (BlockFinally)
New procedure implementation.
* gm2-compiler/SymbolTable.def (MakeModuleCtor):
New procedure definition. (PutPublic) New procedure.
(IsPublic) New procedure. (PutCtor) New procedure.
(IsCtor) New procedure. (GetModuleCtors) New procedure.
(MakeModuleCtor) New procedure. (MakeImport) New procedure.
(MakeImportStatement) New procedure. (IsImport) New procedure.
(IsImportStatement) New procedure. (GetImportModule) New
procedure. (GetImportDeclared) New procedure.
(GetImportStatementList) New procedure.
(GetModuleDefImportStatementList) New procedure.
(GetModuleModImportStatementList) New procedure.
(AppendModuleImportStatement) New procedure.
(AppendModuleOnImportStatement) New procedure.
* gm2-compiler/SymbolTable.mod (MakeModuleCtor):
New procedure definition. (PutPublic) New procedure.
(IsPublic) New procedure. (PutCtor) New procedure.
(IsCtor) New procedure. (GetModuleCtors) New procedure.
(MakeModuleCtor) New procedure. (MakeImport) New procedure.
(MakeImportStatement) New procedure. (IsImport) New procedure.
(IsImportStatement) New procedure. (GetImportModule) New
procedure. (GetImportDeclared) New procedure.
(GetImportStatementList) New procedure.
(GetModuleDefImportStatementList) New procedure.
(GetModuleModImportStatementList) New procedure.
(AppendModuleImportStatement) New procedure.
(AppendModuleOnImportStatement) New procedure.
* gm2-gcc/m2decl.cc (DeclareM2linkGlobals) New function
implementation.
(BuildModuleCtor) New function implementation.
(DeclareModuleCtor) New function implementation.
* gm2-gcc/m2decl.def (DeclareM2linkGlobals) New function.
(BuildModuleCtor) New function. (DeclareModuleCtor)
New function.
* gm2-gcc/m2decl.h (DeclareM2linkGlobals) New function.
(BuildModuleCtor) New function. (DeclareModuleCtor)
New function.
* gm2-gcc/m2options.h (SetScaffoldStatic) New function.
(SetScaffoldDynamic) New function. (SetScaffoldMain)
New function. (SetRuntimeModuleOverride) New function.
* gm2-lang.cc (fscaffold_dynamic) Handle option.
(fscaffold_static) Handle option. (fscaffold_main)
Handle option. (fonlylink) Commented out.
* gm2-libs-iso/M2RTS.def (ConstructModules) New procedure.
(DeconstructModules) New procedure. (RegisterModule)
New procedure. (RequestDependant) New procedure.
* gm2-libs-iso/M2RTS.mod (ConstructModules) New procedure.
(DeconstructModules) New procedure. (RegisterModule)
New procedure. (RequestDependant) New procedure.
Replace termination and initial procedures using a dynamic
data structure. Call upon M2Dependent to solve module
dependencies.
* gm2-libs/M2RTS.def (ConstructModules) New procedure.
(DeconstructModules) New procedure. (RegisterModule)
New procedure. (RequestDependant) New procedure.
* gm2-libs/M2RTS.mod (ConstructModules) New procedure.
(DeconstructModules) New procedure. (RegisterModule)
New procedure. (RequestDependant) New procedure.
Replace termination and initial procedures using a dynamic
data structure. Call upon M2Dependent to solve module
dependencies.
* gm2spec.cc (check_gm2_root): Commented out.
(add_exec_prefix) Commented out. (fonlylink) Commented out.
(fmakeall) Commented out. (fmakeall0) Commented out.
(add_exec_prefix) Commented out. (lang_register_spec_functions)
body commented out.
* lang-specs.h (m2-link-support.h) no longer included.
(M2CPP) defined.
* lang.opt (fuselist) New description. (fmakelist)
New description. (fonlylink) removed. (fscaffold-static)
New option. (fscaffold-dynamic) New option. (ftarget-ranlib=)
Removed. (fscaffold-c) New option. (fscaffold-c++) New option.
(fscaffold-main) New option.
* mc-boot-ch/GM2LINK.c: New file.
* mc-boot/GAssertion.h: Rebuilt.
* mc-boot/GDynamicStrings.c: Rebuilt.
* mc-boot/GDynamicStrings.h: Rebuilt.
* mc-boot/GEnvironment.h: Rebuilt.
* mc-boot/GFIO.c: Rebuilt.
* mc-boot/GFIO.h: Rebuilt.
* mc-boot/GFormatStrings.h: Rebuilt.
* mc-boot/GIndexing.c: Rebuilt.
* mc-boot/GM2EXCEPTION.c: Rebuilt.
* mc-boot/GM2RTS.c: Rebuilt.
* mc-boot/GM2RTS.h: Rebuilt.
* mc-boot/GPushBackInput.c: Rebuilt.
* mc-boot/GRTExceptions.c: Rebuilt.
* mc-boot/GRTint.c: Rebuilt.
* mc-boot/GSYSTEM.h: Rebuilt.
* mc-boot/GStdIO.c: Rebuilt.
* mc-boot/GStringConvert.c: Rebuilt.
* mc-boot/GSysStorage.c:
* mc-boot/Gdecl.c: Rebuilt.
* mc-boot/Gkeyc.c: Rebuilt.
* mc-boot/GmcComment.c: Rebuilt.
* mc-boot/GmcComp.c: Rebuilt.
* mc-boot/GmcDebug.c: Rebuilt.
* mc-boot/GmcMetaError.c: Rebuilt.
* mc-boot/GmcStack.c: Rebuilt.
* mc-boot/GnameKey.c: Rebuilt.
* mc-boot/GsymbolKey.c: Rebuilt.
* mc/decl.mod (isLastStatement) Check if n = NIL
* mc/mcComp.mod: Change spelling to initialization.
and return FALSE.
* tools-src/makeSystem (MINIMAL): New variable.
Use MINIMAL when invoking gm2 to generate the SYSTEM exports.
libgm2/Changelog:
* libm2min/Makefile.am (libm2min_la_M2FLAGS):
Added -fno-scaffold-dynamic -fno-scaffold-main.
* libm2pim/Makefile.am (M2DEFS): Added M2LINK.def.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-05-30 Gaius Mulley <gaius.mulley@southwales.ac.uk>
All m2 linking assistance by the Modula-2 front end is disabled.
cc1gm2 handles the -c option but currently does nothing with the option.
New gcc/testsuite/gm2/link/externalscaffold added to check the compiler
can link trivial application against a hand built scaffold.
gcc/testsuite/gm2/ChangeLog:
* link/externalscaffold: (New regression test). Manual linking
test using external scaffold.
gcc/m2/ChangeLog:
* gm2-compiler/M2Options.def (cflag): New boolean.
(Setc) New procedure. (Getc) New procedure function.
* gm2-compiler/M2Options.mod (Setc): New procedure.
(Getc) New procedure function. Initialize cflag to
FALSE.
* gm2-gcc/m2options.h (Setc): New external function.
(Getc) New external function.
* gm2-lang.cc: Handle OPT_c and call M2Options_Setc.
* lang-specs.h: Remove all link rules for m2.
* lang.opt: Allow m2 to process the -c option.
Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
It's pretty clear that the operand numbers in the MEM_P() checks are
off by one, perhaps due to a copy-and-paste oversight (unlike in most
other places here we're dealing with two outputs).
gcc/
* config/i386/i386.md (bmi2_umul<mode><dwi>3_1): Correct MEM_P()
arguments.
Without this patch, gnat would use `-gnatw?` as the default option for
some of the default warnings.
gcc/ada/
* erroutc.adb (Get_Warning_Option): Don't consider `?` as a
valid option switch.
This enables better integration with tools that handle GNAT's output.
gcc/ada/
* erroutc.ads (Get_Warning_Option): New function returning the
option responsible for a warning if it exists.
* erroutc.adb (Get_Warning_Option): Likewise.
(Get_Warning_Tag): Rely on Get_Warning_Option when possible.
* errout.adb (Output_JSON_Message): Emit option field.
When implementing structural subprogram variants we ignored them in
expansion of the pragma itself, but not in expansion of a recursive
subprogram call. Now fixed.
gcc/ada/
* exp_ch6.adb (Check_Subprogram_Variant): Ignore structural
variants.
Code cleanup; semantics is unaffected.
gcc/ada/
* osint.adb (Locate_File): Change variable to constant and
initialize it by concatenation of directory, file name and NUL.
The GNAT behaviour regarding the Ada RM requirement to support Address
clauses for imported subprograms was documented twice: in section about
packed types (which was a mistake) and in section about address clauses
(where it belongs).
Cleanup related to the use of packed arrays for bitset operations to
detect uses of uninitialized scalars in GNAT.
gcc/ada/
* doc/gnat_rm/implementation_advice.rst (Packed Types): Remove
duplicated and wrongly placed paragraph.
* gnat_rm.texi: Regenerate.
This enables tools that ingest GNAT's output to properly classify these
messages.
gcc/ada/
* inline.adb (Check_Package_Body_For_Inlining): Add insertion
character.
This caused these warnings not to be tagged with the switch causing
them, which is an issue for tools ingesting GNAT's output.
gcc/ada/
* sem_elab.adb (Process_Conditional_ABE_Access_Taken): Add '.f'
insertion characters.
While cleaning up and modifying code for unreferenced warnings we
removed all calls to Defer_Reference, which was the only routine that
populated the Deferred_References table. Consequently, all the code
related to this table became dead.
gcc/ada/
* lib-xref.ads (Deferred_Reference_Entry, Defer_Reference,
Process_Deferred_References, Has_Deferred_Reference): Remove
client API.
* lib-xref.adb (Deferred_References, Defer_Reference,
Has_Deferred_Reference, Process_Deferred_References): Remove
implementation.
* frontend.adb, sem_ch11.adb, sem_ch5.adb, sem_res.adb,
sem_util.adb, sem_warn.adb: Remove uses of Deferred_References.
This patch fixes a bug whereby if a function body has local objects that
are finalizable, and has a return statement that requires generation of
transient finalizable temps, and there are dynamic-sized objects
requiring pushing/popping the (primary) stack at run time, and the
function body has exception handlers, then incorrect code is
generated. In particular, the transient objects are finalized after they
have been deallocated. This can cause seg faults, corrupted heap, and
the like.
Note that if there are no dynamic-sized objects, then the bug does
not occur, because the back end allocates objects of compile-time-known
size based on where they are referenced, rather than which local
block they are declared in.
This patch relies on the fact that an At_End handler and regular
exception handlers CAN coexist in the same handled statement sequence,
which was not true some years ago.
gcc/ada/
* exp_ch7.adb (Wrap_HSS_In_Block): Do not create a new block in
the case of function bodies. We include all subprogram bodies,
because it's harmless for procedures. We cannot easily avoid
creating this block in ALL cases, because some transformations
of (e.g.) task bodies end up moving some code such that the
wrong exception handlers apply to that code.
(Build_Finalizer_Call): Remove code for creating a new block.
This was unreachable code, given that Wrap_HSS_In_Block has
already done that, but with the above change to
Wrap_HSS_In_Block, this code becomes reachable, and triggers
essentially the same bug.
* exp_ch7.ads: Adjust comment.
This patch corrects an error in the compiler whereby spurious
unreferenced warnings are generated on formal parameters of null generic
subprograms.
These changes also fix the parsing of aspects on formal parameters such
that the aspects now get properly set for all formal parameters in a
parameter list.
gcc/ada/
* par-ch6.adb (P_Formal_Part): Set Aspect_Specifications on all
formals instead of just the last in a formal id list.
* sem_ch6.adb (Analyze_Null_Procedure): Mark expanded null
generic procedures as trivial in order to avoid spurious
unreferenced warnings.
Both the `System.Mmap` and `System.Object_Reader` packages are defining
entities named `Offset` and they are both `use`d at the top of
s-dwalin.adb.
Therefore, the references to `Offset` throughout this file are
ambiguous, and GNAT is supposed to complain. Since it does not for the
moment, we fix the ambiguity by declaring a subtype `Offset` at the top
of the file simply renames `System.Object_Reader.Offset`.
gcc/ada/
* libgnat/s-dwalin.adb: Add a subtype declaration to fix the
ambiguity.
The expression given in a Static_Predicate aspect specification is
required to be predicate-static. The implementation of this compile-time
check was incorrect in some cases. There were problems in both
directions: expressions that are not predicate-static were incorrectly
treated as though they were and vice versa. This led to both accepting
invalid code and to rejecting valid code.
gcc/ada/
* sem_ch13.adb (Is_Predicate_Static): Do not generate warnings
about subexpressions of enclosing expressions. Generate warnings
for predicates that are known to be always true or always false,
except in the case where the predicate is expressed as a Boolean
literal. Deal with non-predicate-static expressions that have
been transformed into predicate-static expressions. Add missing
Is_Type_Ref call to N_Membership_Test case.
The presence of the discriminants prevents the values associated with the
components of the parent type from being put into the sub-aggregate built
for the _Parent component.
gcc/ada/
* exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End_Aggregate):
Skip the discriminants at the start of the component list before
looking for the components inherited from the parent in the case
of a tagged extension.
The left-overs of the old freezing code in Make_DT are now redundant since
the semantic analyzer performs the same task for the 'Access attribute.
gcc/ada/
* exp_disp.adb (Make_DT): Remove remaining freezing code.
There is no need to analyze expression functions that are primitives of a
tagged type for its dispatch table because they will be analyzed at the end
of the current scope.
gcc/ada/
* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Don't analyze
the body of an expression function in the case of a dispatch table.
Changes in GNATprove (translation to Why3 and provers) result in proofs
being much less automatic, and requiring ghost code to detail
intermediate steps. In some cases, it is better to use the new By
mechanism to prove assertions in steps, as this avoids polluting the
proof context for other proofs. For that reason, add units s-spark.ads
and s-spcuop.ads/b to the runtime sources.
gcc/ada/
* Makefile.rtl: Add new units.
* libgnat/s-aridou.adb (Scaled_Divide): Add ghost code for provers.
* libgnat/s-spcuop.adb: New unit for ghost cut operations.
* libgnat/s-spcuop.ads: New unit for ghost cut operations.
* libgnat/s-spark.ads: New unit.
Mention when security hardening features are available in other
languages.
Expand the strub documentation a little, for clarity and completeness.
Add missing 'aliased' and attribute to variables in strub example.
gcc/ada/
* doc/gnat_rm/security_hardening_features.rst: Mention
availability in other languages when applicable.
(Stack Scrubbing): Associate the attribute with types, expand
some comments, fix the example involving access to variables.
* gnat_rm.texi: Regenerate.
The previous change introduced a backward incompatibility in the handling
of a user-defined "=" operator for a class-wide type of a tagged type: it
would previously hide the predefined "=" operator of the tagged type in
the private case, but it no longer does in this case, while it still does
in the nonprivate case.
This hiding is a non-portability, but is fundamentally what the compiler
implements, instead of the RM rule which requires homographs. The reason
lies in the implementation of the "=" operator in GNAT: internally, there
is not a "=" predefined operator for every nonlimited type, but instead
there is a single, universal "=" predefined operator for all the nonlimited
types. The consequence is that the hiding rule implemented in GNAT for "="
is effectively that a user-declared symmetrical "=" operator returning
boolean hides the predefined "=" operator of any type that is covered by
the user-declared operator.
Whether it is desirable to implement the exact RM rule in GNAT is to be
discussed, but existing code relies on the non-portability and would thus
need to be changed.
gcc/ada/
* sem_ch6.adb (New_Overloaded_Entity): Deal specifically with the
overriding of the "=" operator for tagged types.
When static dispatch tables are built for library-level tagged types, the
primitives (the subprogram themselves) are frozen; that's necessary because
their address is taken. However, their profile, i.e. all the types present
therein, is also frozen, which is not necessary after AI05-019 and is also
inconsistent with the handling of attribute references.
The change also removes a couple of pragma Inline on subprograms that are
too large for inlining to bring any benefit.
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Adjust call to Make_DT.
* exp_disp.ads (Building_Static_DT): Remove pragma Inline.
(Building_Static_Secondary_DT): Likewise.
(Convert_Tag_To_Interface): Likewise.
(Make_DT): Remove second parameter.
* exp_disp.adb (Make_DT): Likewise.
(Check_Premature_Freezing): Delete.
Pass Do_Freeze_Profile as False in call to Freeze_Entity.
* freeze.ads (Freezing_Library_Level_Tagged_Type): Delete.
* freeze.adb (Freeze_Profile): Remove obsolete code.
(Freeze_Entity): Tweak comment.
After changes in GNATprove, adapt proof. Simply move an assertion up
before it is first needed here.
gcc/ada/
* libgnat/s-arit32.adb (Scaled_Divide32): Move assertion up.
The internal unit System.Generic_Array_Operations defines only generic
subprograms. Thus, pragma Assertion_Policy inside the spec has no
effect, as each instantiation is only subject to the assertion policy at
the program point of the instantiation. Remove this confusing pragma,
and add the pragma inside each generic body making use of additional
assertions or ghost code, so that running time of instantiations is not
impacted by assertions meant for formal verification.
gcc/ada/
PR ada/105303
* libgnat/s-gearop.adb: Add pragma Assertion_Policy in generic
bodies making use of additional assertions or ghost code.
* libgnat/s-gearop.ads: Remove confusing Assertion_Policy.
As a result of other recent changes, the Convert_To_Return_False flag
is never set. The flag can be therefore be deleted.
gcc/ada/
* exp_ch11.adb (Expand_N_Raise_Expression): Remove
Convert_To_Return_False test.
* gen_il-fields.ads: Remove Convert_To_Return_False field.
* gen_il-gen-gen_nodes.adb: Remove use of
Convert_To_Return_False field.
* sinfo.ads: Remove comment describing Convert_To_Return_False
flag.
This patch adds empty constructors to the functional containers so that
we can use them in expression functions.
gcc/ada/
* libgnat/a-cofuma.ads, libgnat/a-cofuma.adb,
libgnat/a-cofuse.ads, libgnat/a-cofuse.adb,
libgnat/a-cofuve.ads, libgnat/a-cofuve.adb: Add empty
constructors.
Removal of the previous kernel registration scheme unearthed mistakes in
the new one, which were:
- The new kernel registration code relied on the binder expansion phase,
which didn't happen because the registration code was already
generated by the binder.
- The kernel handle passed to CUDA_Register_Function was the first eight
bytes of the code of the host-side procedure representing the kernel
rather than its address.
gcc/ada/
* bindgen.adb (Gen_CUDA_Init): Remove code generating CUDA
definitions.
(Gen_CUDA_Defs): New function, generating definitions
initialized by Gen_CUDA_Init.
(Gen_Output_File_Ada): Call Gen_CUDA_Defs instead of
Gen_CUDA_Init.
(Gen_Adainit): Call Gen_CUDA_Init.
The first part of the following testcase (m1-m3 macros and its use)
regressed with my PR89971 fix, but as the m1,m4-m5 and its use part shows,
the problem isn't new, we can emit a CPP_PADDING token to avoid it from
being adjacent to whatever comes after the __VA_OPT__ (in this case there
is nothing afterwards, true).
In most cases these CPP_PADDING tokens don't matter, all other
callers of cpp_get_token_with_location either ignore CPP_PADDING tokens
completely (e.g. c_lex_with_flags) or they just remember them and
take them into account when printing stuff whether there should be
added whitespace or not (scan_translation_unit + token_streamer::stream).
So, I think we should just ignore CPP_PADDING tokens the same way in
_cpp_parse_expr.
2022-05-27 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/105732
* expr.cc (_cpp_parse_expr): Handle CPP_PADDING by just another
token.
* c-c++-common/cpp/va-opt-10.c: New test.