https://gcc.gnu.org/g:da470844aebd0836ce5b6921be62be954e1f8b52
commit r14-11085-gda470844aebd0836ce5b6921be62be954e1f8b52 Author: Gaius Mulley <gaiusm...@gmail.com> Date: Fri Dec 13 14:10:19 2024 +0000 [PATCH] PR modula2/115328: use enable forward bool and set default true This patch introduces GetEnableForward and SetEnableForward against which the forward procedure declaration feature is checked. Currently this is set as default true. gcc/m2/ChangeLog: PR modula2/115328 * gm2-compiler/M2Options.def (GetEnableForward): New procedure function. (SetEnableForward): New procedure. * gm2-compiler/M2Options.mod (GetEnableForward): New procedure function. (SetEnableForward): New procedure. (EnableForward): New boolean. * gm2-compiler/P1SymBuild.mod (EndBuildForward): Check GetEnableForward and generate an error message if false. gcc/testsuite/ChangeLog: PR modula2/115328 * gm2/pim/fail/forward.mod: Move to... * gm2/pim/pass/forward.mod: ...here. (cherry picked from commit 548afd73cdbf310403a1e3f34226372c16c29706) Signed-off-by: Gaius Mulley <gaiusm...@gmail.com> Diff: --- gcc/m2/gm2-compiler/M2Options.def | 14 ++++++++++++++ gcc/m2/gm2-compiler/M2Options.mod | 24 +++++++++++++++++++++++- gcc/m2/gm2-compiler/P1SymBuild.mod | 6 +++--- gcc/testsuite/gm2/pim/{fail => pass}/forward.mod | 0 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gcc/m2/gm2-compiler/M2Options.def b/gcc/m2/gm2-compiler/M2Options.def index baa5d7ec897f..1f483e6611ec 100644 --- a/gcc/m2/gm2-compiler/M2Options.def +++ b/gcc/m2/gm2-compiler/M2Options.def @@ -1121,6 +1121,20 @@ PROCEDURE GetDebugTraceLine () : BOOLEAN ; PROCEDURE GetDebugFunctionLineNumbers () : BOOLEAN ; +(* + GetEnableForward - return EnableForward. +*) + +PROCEDURE GetEnableForward () : BOOLEAN ; + + +(* + SetEnableForward - set EnableForward to value. +*) + +PROCEDURE SetEnableForward (value: BOOLEAN) ; + + (* FinaliseOptions - once all options have been parsed we set any inferred values. diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod index 4048144f48e5..8f4e326beb25 100644 --- a/gcc/m2/gm2-compiler/M2Options.mod +++ b/gcc/m2/gm2-compiler/M2Options.mod @@ -76,6 +76,7 @@ VAR UselistFilename, RuntimeModuleOverride, CppArgs : String ; + EnableForward, DebugFunctionLineNumbers, DebugTraceQuad, (* -fm2-debug-trace=quad. *) DebugTraceLine, (* -fm2-debug-trace=line. *) @@ -2008,6 +2009,26 @@ BEGIN END GetDumpDecl ; +(* + GetEnableForward - return EnableForward. +*) + +PROCEDURE GetEnableForward () : BOOLEAN ; +BEGIN + RETURN EnableForward +END GetEnableForward ; + + +(* + SetEnableForward - set EnableForward to value. +*) + +PROCEDURE SetEnableForward (value: BOOLEAN) ; +BEGIN + EnableForward := value +END SetEnableForward ; + + BEGIN cflag := FALSE ; (* -c. *) RuntimeModuleOverride := InitString (DefaultRuntimeModuleOverride) ; @@ -2099,5 +2120,6 @@ BEGIN DumpQuad := FALSE ; DumpGimple := FALSE ; M2Dump := NIL ; - M2DumpFilter := NIL + M2DumpFilter := NIL ; + EnableForward := TRUE END M2Options. diff --git a/gcc/m2/gm2-compiler/P1SymBuild.mod b/gcc/m2/gm2-compiler/P1SymBuild.mod index cd42417a3948..e916fb6c66dc 100644 --- a/gcc/m2/gm2-compiler/P1SymBuild.mod +++ b/gcc/m2/gm2-compiler/P1SymBuild.mod @@ -32,7 +32,7 @@ FROM M2MetaError IMPORT MetaErrorString2, MetaError0, MetaError1, FROM DynamicStrings IMPORT String, Slice, InitString, KillString, EqualCharStar, RIndex, Mark, ConCat ; FROM M2Printf IMPORT printf0, printf1, printf2 ; -FROM M2Options IMPORT Iso ; +FROM M2Options IMPORT Iso, GetEnableForward ; FROM M2Reserved IMPORT ImportTok, ExportTok, QualifiedTok, UnQualifiedTok, NulTok, VarTok, ArrayTok, BuiltinTok, InlineTok ; @@ -1074,10 +1074,10 @@ VAR BEGIN ProcSym := OperandT (1) ; tok := OperandTok (1) ; - IF NOT Iso + IF NOT GetEnableForward () THEN MetaErrorT0 (forwardPos, - 'forward declaration is only allowed in the ISO dialect of Modula-2') + 'forward declaration has not been enabled, use -fiso or -fenable-forward to enable forward procedure declarations') END ; IF GetProcedureDefined (ProcSym, ForwardProcedure) THEN diff --git a/gcc/testsuite/gm2/pim/fail/forward.mod b/gcc/testsuite/gm2/pim/pass/forward.mod similarity index 100% rename from gcc/testsuite/gm2/pim/fail/forward.mod rename to gcc/testsuite/gm2/pim/pass/forward.mod