1 (* M2Options.def initializes the user options.
3 Copyright (C) 2001-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 DEFINITION MODULE M2Options ;
27 Date : 27/5/87 [$Date: 2013/08/14 20:39:40 $]
28 SYSTEM : UNIX (GNU Modula-2)
29 Description: Initializes the user options in the Modula-2 compiler.
30 Version : $Revision: 1.31 $
33 FROM SYSTEM IMPORT ADDRESS ;
34 FROM DynamicStrings IMPORT String ;
35 FROM m2linemap IMPORT location_t ;
37 EXPORT QUALIFIED SetReturnCheck, SetNilCheck, SetCaseCheck,
38 SetCheckAll, SetVerboseUnbounded, SetQuiet, SetCpp, GetCpp,
39 (* SetMakeall, SetMakeall0, SetIncludePath, *) SetAutoInit,
40 SetUnboundedByReference,
41 SetSearchPath, SetISO, SetPIM, SetPIM2, SetPIM3, SetPIM4,
42 SetPositiveModFloor, SetCompilerDebugging, SetExceptions,
43 SetStudents, SetPedantic, SetPedanticParamNames, SetPedanticCast,
44 SetExtendedOpaque, SetXCode, SetQuadDebugging, SetSources,
46 SetSwig, DisplayVersion, SetOptimizing, SetForcedLocation,
47 SetCC1Quiet, SetWholeProgram, SetDebugTraceQuad, SetDebugTraceAPI,
48 SetVerbose, SetM2g, GetM2g,
49 GetISO, GetPIM, GetPIM2, GetPIM3, GetPIM4,
51 SetFloatValueCheck, GetFloatValueCheck,
52 SetWholeValueCheck, GetWholeValueCheck,
54 SetIndex, SetRange, SetWholeDiv, SetStrictTypeChecking,
56 Iso, Pim, Pim2, Pim3, Pim4,
58 Pedantic, Verbose, Statistics,
59 UnboundedByReference, VerboseUnbounded,
60 Profiling, Coding, Optimizing,
61 OptimizeBasicBlock, OptimizeUncalledProcedures,
62 OptimizeCommonSubExpressions,
63 StudentChecking, WholeProgram,
65 WholeDivChecking, WholeValueChecking,
66 IndexChecking, RangeChecking,
67 ReturnChecking, CaseElseChecking,
70 UnusedVariableChecking, UnusedParameterChecking,
71 SetUnusedVariableChecking, SetUnusedParameterChecking,
72 Quiet, LineDirectives, StrictTypeChecking,
73 CPreProcessor, Xcode, ExtendedOpaque,
75 PedanticParamNames, PedanticCast,
76 DisplayQuadruples, DebugTraceQuad, DebugTraceAPI,
77 CompilerDebugging, GenerateDebugging, GenerateLineDebug,
78 DumpSystemExports, GenerateSwig, Exceptions,
79 OverrideLocation, FinaliseOptions,
80 DebugBuiltins, setdefextension, setmodextension,
81 SetStatistics, SetWall, SetSaveTemps, SetSaveTempsDir,
83 CppProg, CppArg, CppCommandLine, CppRemember,
84 SetDebugFunctionLineNumbers, DebugFunctionLineNumbers,
85 SetGenerateStatementNote, GenerateStatementNote ;
89 Iso, (* -fiso use ISO SYSTEM.def *)
90 Pim, (* -fpim use PIM [234] SYSTEM.def *)
91 Pim2, (* -fpim2 use strict rules. *)
92 Pim3, (* -fpim3 use strict rules. *)
93 Pim4, (* -fpim4 use strict rules. *)
94 PositiveModFloorDiv, (* force PIM4 behaviour for DIV and MOD *)
95 CompilerDebugging, (* -fd internal debugging messages *)
96 DebugTraceQuad, (* -fdebug-trace-quad *)
97 DebugTraceAPI, (* -fdebug-trace-api *)
98 GenerateDebugging, (* -g option to generate info for gdb/dbx *)
99 GenerateLineDebug, (* -gline to generate line debugging. *)
100 Verbose, (* -verbose produce verbose error messages. *)
101 Pedantic, (* -pedantic be pedantic on error checking. *)
102 PedanticParamNames, (* -Wpedantic-param-names *)
103 PedanticCast, (* -Wpedantic-cast warns if sizes differ. *)
104 Statistics, (* -fstatistics information about code *)
105 StudentChecking, (* -Wstudents checks for common student errs*)
106 DisplayQuadruples, (* -Wq option will display quadruples. *)
107 UnboundedByReference, (* -funbounded-by-reference *)
108 VerboseUnbounded, (* -Wverbose-unbounded *)
109 OptimizeUncalledProcedures, (* -Ouncalled removes uncalled procedures *)
110 OptimizeBasicBlock, (* -Obb create basic blocks and optimize. *)
111 OptimizeCommonSubExpressions, (* -Ocse optimize common subexpressions *)
112 WholeProgram, (* -fwhole-program optimization. *)
113 NilChecking, (* -fnil makes compiler test for pointer *)
115 WholeDivChecking, (* -fwholediv produces code to raise an *)
116 (* exception if a whole number divide by *)
118 WholeValueChecking, (* -fwholevalue produces code to raise an *)
119 (* exception if a whole value variable is *)
120 (* about to exceed the type limits. *)
121 FloatValueChecking, (* -ffloatvalue produces code to raise an *)
122 (* exception if a floating point variable *)
123 (* is about to exceed the type limits. *)
124 IndexChecking, (* -findex array bounds checking. *)
125 RangeChecking, (* -frange assignment, set values, *)
126 (* constructor values in range. *)
127 ReturnChecking, (* -freturn checks that functions always *)
128 (* exit with a RETURN statement. *)
129 CaseElseChecking, (* -fcase checks program does not need an *)
130 (* else statement within an case statement *)
131 (* when the user omits one *)
132 VariantValueChecking, (* should we check all values are present *)
133 (* in a variant record? True for ISO and *)
135 Quiet, (* -fquiet option specified. *)
136 LineDirectives, (* should compiler understand preprocessor *)
137 (* # linenumber "filename" markers? *)
138 StrictTypeChecking, (* -fm2-strict-type experimental checker. *)
139 CPreProcessor, (* must we run the cpp on the source? *)
140 Xcode, (* should errors follow Xcode format? *)
141 ExtendedOpaque, (* do we allow non pointer opaque types? *)
142 DumpSystemExports, (* print all inbuilt system items? *)
143 GenerateSwig, (* should we generate a swig interface file?*)
144 Exceptions, (* should we generate exception code? *)
145 UnusedVariableChecking, (* should we warn about unused variables? *)
146 UnusedParameterChecking, (* should we warn about unused parameters? *)
147 LowerCaseKeywords, (* should keywords in errors be in lower? *)
148 DebugBuiltins, (* should we always call a real function? *)
149 AutoInit, (* -fauto-init assigns pointers to NIL. *)
150 SaveTemps, (* -save-temps save all temporary files. *)
152 DebugFunctionLineNumbers,
153 GenerateStatementNote,
156 Profiling : BOOLEAN ;
160 DisplayVersion - displays the version of the compiler.
163 PROCEDURE DisplayVersion (mustExit: BOOLEAN) ;
167 SetWholeProgram - sets the WholeProgram flag (-fwhole-program).
170 PROCEDURE SetWholeProgram (value: BOOLEAN) ;
174 SetAutoInit - set the auto initialization flag to value. If the value
175 is true then all pointers are automatically
179 PROCEDURE SetAutoInit (value: BOOLEAN) : BOOLEAN ;
183 SetReturnCheck - set return statement checking in procedure functions
187 PROCEDURE SetReturnCheck (value: BOOLEAN) : BOOLEAN ;
191 SetNilCheck - set access through NIL violation runtime checking to value.
194 PROCEDURE SetNilCheck (value: BOOLEAN) : BOOLEAN ;
198 SetCaseCheck - set else case checking to, value.
201 PROCEDURE SetCaseCheck (value: BOOLEAN) : BOOLEAN ;
205 SetCheckAll - set all runtime checking to, value.
208 PROCEDURE SetCheckAll (value: BOOLEAN) : BOOLEAN ;
212 SetVerboseUnbounded - sets the VerboseUnbounded flag to, value.
215 PROCEDURE SetVerboseUnbounded (value: BOOLEAN) : BOOLEAN ;
219 SetQuiet - sets the quiet flag to, value.
222 PROCEDURE SetQuiet (value: BOOLEAN) : BOOLEAN ;
226 SetCC1Quiet - sets the cc1quiet flag to, value.
229 PROCEDURE SetCC1Quiet (value: BOOLEAN) ;
236 PROCEDURE SetCpp (value: BOOLEAN) : BOOLEAN ;
240 GetCpp - returns TRUE if the C preprocessor was used.
243 PROCEDURE GetCpp () : BOOLEAN ;
247 SetM2g - set the -fm2-g flag.
250 PROCEDURE SetM2g (value: BOOLEAN) : BOOLEAN ;
254 GetM2g - returns TRUE if the -fm2-g flags was used.
257 PROCEDURE GetM2g () : BOOLEAN ;
261 SetLowerCaseKeywords - set the lower case keyword flag and return the result.
264 PROCEDURE SetLowerCaseKeywords (value: BOOLEAN) : BOOLEAN ;
270 PROCEDURE SetMakeall (value: BOOLEAN) : BOOLEAN ;
277 PROCEDURE SetMakeall0 (value: BOOLEAN) : BOOLEAN ;
284 PROCEDURE SetIncludePath (arg: ADDRESS) : BOOLEAN ;
289 SetUnboundedByReference -
292 PROCEDURE SetUnboundedByReference (value: BOOLEAN) : BOOLEAN ;
299 PROCEDURE SetSearchPath (arg: ADDRESS) ;
306 PROCEDURE SetISO (value: BOOLEAN) ;
313 PROCEDURE SetPIM (value: BOOLEAN) ;
320 PROCEDURE SetPIM2 (value: BOOLEAN) ;
327 PROCEDURE SetPIM3 (value: BOOLEAN) ;
334 PROCEDURE SetPIM4 (value: BOOLEAN) ;
338 SetPositiveModFloor -
341 PROCEDURE SetPositiveModFloor (value: BOOLEAN) ;
345 SetWholeDiv - sets the whole division flag.
348 PROCEDURE SetWholeDiv (value: BOOLEAN) ;
352 SetIndex - sets the runtime array index checking flag.
355 PROCEDURE SetIndex (value: BOOLEAN) ;
359 SetRange - sets the runtime range checking flag.
362 PROCEDURE SetRange (value: BOOLEAN) ;
369 PROCEDURE SetExceptions (value: BOOLEAN) ;
376 PROCEDURE SetStudents (value: BOOLEAN) ;
383 PROCEDURE SetPedantic (value: BOOLEAN) ;
387 SetPedanticParamNames -
390 PROCEDURE SetPedanticParamNames (value: BOOLEAN) ;
397 PROCEDURE SetPedanticCast (value: BOOLEAN) ;
404 PROCEDURE SetExtendedOpaque (value: BOOLEAN) ;
411 PROCEDURE SetXCode (value: BOOLEAN) ;
415 SetCompilerDebugging - turn on internal compiler debugging.
418 PROCEDURE SetCompilerDebugging (value: BOOLEAN) ;
422 SetQuadDebugging - display the quadruples (internal debugging).
425 PROCEDURE SetQuadDebugging (value: BOOLEAN) ;
432 PROCEDURE SetDebugTraceQuad (value: BOOLEAN) ;
439 PROCEDURE SetDebugTraceAPI (value: BOOLEAN) ;
443 SetDebugFunctionLineNumbers - turn DebugFunctionLineNumbers on/off
444 (used internally for debugging).
447 PROCEDURE SetDebugFunctionLineNumbers (value: BOOLEAN) ;
451 SetGenerateStatementNote - turn on generation of nops if necessary
452 to generate pedalogical single stepping.
455 PROCEDURE SetGenerateStatementNote (value: BOOLEAN) ;
462 PROCEDURE SetSources (value: BOOLEAN) ;
466 SetDumpSystemExports -
469 PROCEDURE SetDumpSystemExports (value: BOOLEAN) ;
476 PROCEDURE SetSwig (value: BOOLEAN) ;
483 PROCEDURE SetOptimizing (value: CARDINAL) ;
487 OverrideLocation - possibly override the location value, depending upon
488 whether the -flocation= option was used.
491 PROCEDURE OverrideLocation (location: location_t) : location_t ;
495 SetForcedLocation - sets the location for the lifetime of this compile to, location.
496 This is primarily an internal debugging switch.
499 PROCEDURE SetForcedLocation (location: location_t) ;
503 SetUnusedVariableChecking - assigns the UnusedVariableChecking to value.
506 PROCEDURE SetUnusedVariableChecking (value: BOOLEAN) ;
510 SetUnusedParameterChecking - assigns the UnusedParameterChecking to value.
513 PROCEDURE SetUnusedParameterChecking (value: BOOLEAN) ;
517 SetStrictTypeChecking - assigns the StrictTypeChecking flag to value.
520 PROCEDURE SetStrictTypeChecking (value: BOOLEAN) ;
527 PROCEDURE setdefextension (arg: ADDRESS) ;
534 PROCEDURE setmodextension (arg: ADDRESS) ;
538 SetStatistics - turn on/off generate of compile time statistics.
541 PROCEDURE SetStatistics (on: BOOLEAN) ;
545 SetVerbose - set the Verbose flag to, value. It returns TRUE.
548 PROCEDURE SetVerbose (value: BOOLEAN) : BOOLEAN ;
552 CppProg - sets the cpp program to be, program.
555 PROCEDURE CppProg (program: ADDRESS) ;
559 CppArg - sets the option and arg in the cpp command line.
562 PROCEDURE CppArg (opt, arg: ADDRESS; joined: BOOLEAN) ;
566 CppCommandLine - returns the Cpp command line and all arguments.
569 PROCEDURE CppCommandLine () : String ;
573 CppRemember - remember a string, s, as a cpp related argument.
574 The string, s, is not garbage collected.
577 PROCEDURE CppRemember (s: String) ;
581 GetISO - return TRUE if -fiso was present on the command line.
584 PROCEDURE GetISO () : BOOLEAN ;
588 GetPIM - return TRUE if -fpim was present on the command line.
591 PROCEDURE GetPIM () : BOOLEAN ;
595 GetPIM2 - return TRUE if -fpim2 was present on the command line.
598 PROCEDURE GetPIM2 () : BOOLEAN ;
602 GetPIM3 - return TRUE if -fpim3 was present on the command line.
605 PROCEDURE GetPIM3 () : BOOLEAN ;
609 GetPIM4 - return TRUE if -fpim4 was present on the command line.
612 PROCEDURE GetPIM4 () : BOOLEAN ;
616 GetPositiveModFloor - return TRUE if -fpositive-mod-floor was present
620 PROCEDURE GetPositiveModFloor () : BOOLEAN ;
624 GetFloatValueCheck - return TRUE if -ffloatvalue was present on the
628 PROCEDURE GetFloatValueCheck () : BOOLEAN ;
632 SetFloatValueCheck - set depending upon the -ffloatvalue.
635 PROCEDURE SetFloatValueCheck (value: BOOLEAN) ;
639 GetWholeValueCheck - return TRUE if -fwholevalue was present on the
643 PROCEDURE GetWholeValueCheck () : BOOLEAN ;
647 SetWholeValueCheck - set depending upon the -fwholevalue.
650 PROCEDURE SetWholeValueCheck (value: BOOLEAN) ;
654 SetWall - set all warnings to, value.
657 PROCEDURE SetWall (value: BOOLEAN) ;
661 SetSaveTemps - turn on/off -save-temps.
664 PROCEDURE SetSaveTemps (value: BOOLEAN) ;
668 SetSaveTempsDir - turn on/off -save-temps specifying the
672 PROCEDURE SetSaveTempsDir (arg: ADDRESS) ;
676 FinaliseOptions - once all options have been parsed we set any inferred
680 PROCEDURE FinaliseOptions ;