]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR modula2/115328: use enable forward bool and set default true
authorGaius Mulley <gaiusmod2@gmail.com>
Mon, 9 Dec 2024 13:56:37 +0000 (13:56 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Mon, 9 Dec 2024 13:56:37 +0000 (13:56 +0000)
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.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2Options.def
gcc/m2/gm2-compiler/M2Options.mod
gcc/m2/gm2-compiler/P1SymBuild.mod
gcc/testsuite/gm2/pim/pass/forward.mod [moved from gcc/testsuite/gm2/pim/fail/forward.mod with 100% similarity]

index baa5d7ec897f0c3f992fc0d858d9dc1a54d7e2ba..1f483e6611ec6761ca26d51912829526580a96a5 100644 (file)
@@ -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.
index 4048144f48e5451007a33a9036ec088a21f5ab39..8f4e326beb25005b74fb603b0622fa2dbaf8227e 100644 (file)
@@ -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.
index cd42417a39483268da8bbd2ca3d9562f896ffce3..e916fb6c66dce0882b2234aa826723488944c8e4 100644 (file)
@@ -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