aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2024-12-09 13:56:37 +0000
committerGaius Mulley <gaiusmod2@gmail.com>2024-12-09 13:56:37 +0000
commit548afd73cdbf310403a1e3f34226372c16c29706 (patch)
tree24c8ae3dbb21c740bdb1c0f58426adde16d9d2ba /gcc
parent2e958291ff68d9bff1092895a14b6763de56823b (diff)
downloadgcc-548afd73cdbf310403a1e3f34226372c16c29706.zip
gcc-548afd73cdbf310403a1e3f34226372c16c29706.tar.gz
gcc-548afd73cdbf310403a1e3f34226372c16c29706.tar.bz2
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. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/m2/gm2-compiler/M2Options.def14
-rw-r--r--gcc/m2/gm2-compiler/M2Options.mod24
-rw-r--r--gcc/m2/gm2-compiler/P1SymBuild.mod6
-rw-r--r--gcc/testsuite/gm2/pim/pass/forward.mod (renamed from gcc/testsuite/gm2/pim/fail/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 baa5d7e..1f483e6 100644
--- a/gcc/m2/gm2-compiler/M2Options.def
+++ b/gcc/m2/gm2-compiler/M2Options.def
@@ -1122,6 +1122,20 @@ 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 4048144..8f4e326 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 cd42417..e916fb6 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
index 123e006..123e006 100644
--- a/gcc/testsuite/gm2/pim/fail/forward.mod
+++ b/gcc/testsuite/gm2/pim/pass/forward.mod