The RULES option allows or disallows certain language capabilities and lets you choose semantics when alternatives are available. It can help you diagnose common programming errors.
.-,--------------------------------------------------------------. V .-IBM-. | >>-RULES--(----+-+-ANS-+----------------------------------------------------+-+--)->< | .-BYNAME---. | +-+-NOBYNAME-+-----------------------------------------------+ | .-COMPLEX-------------------------. | +-+-NOCOMPLEX--+------------------+-+------------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-CONTROLLED---. | +-+-NOCONTROLLED-+-------------------------------------------+ | .-NODECSIZE-. | +-+-DECSIZE---+----------------------------------------------+ | .-ELSEIF---. | +-+-NOELSEIF-+-----------------------------------------------+ | .-EVENDEC---. | +-+-NOEVENDEC-+----------------------------------------------+ | .-GLOBAL-------------------------. | +-+-NOGLOBAL--+------------------+-+-------------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-GLOBALDO---. | +-+-NOGLOBALDO-+---------------------------------------------+ | .-GOTO-------------------------------. | +-+-NOGOTO--+------------------------+-+---------------------+ | | .-STRICT-------. | | | '-(--+-LOOSE--------+--)-' | | '-LOOSEFORWARD-' | | .-NOLAXBIF-. | +-+-LAXBIF---+-----------------------------------------------+ | .-LAXCONV-------------------------. | +-+-NOLAXCONV--+------------------+-+------------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-NOLAXCTL-. | +-+-LAXCTL---+-----------------------------------------------+ | .-NOLAXDCL-. | +-+-LAXDCL---+-----------------------------------------------+ | .-NOLAXDEF-. | +-+-LAXDEF---+-----------------------------------------------+ | .-LAXEXPORTS---. | +-+-NOLAXEXPORTS-+-------------------------------------------+ | .-LAXFIELDS---. | +-+-NOLAXFIELDS-+--------------------------------------------+ | .-LAXINTERFACE---. | +-+-NOLAXINTERFACE-+-----------------------------------------+ | .-LAXENTRY-------------------------. | +-+-NOLAXENTRY--+------------------+-+-----------------------+ | | .-STRICT-. | | | '-(--+-LOOSE--+--)-' | | .-NOLAXIF-. | +-+-LAXIF---+------------------------------------------------+ | .-LAXINOUT---. | +-+-NOLAXINOUT-+---------------------------------------------+ | .-LAXLINK---. | +-+-NOLAXLINK-+----------------------------------------------+ | .-LAXMARGINS---------------------------. | +-+-NOLAXMARGINS--+--------------------+-+-------------------+ | | .-STRICT---. | | | '-(--+-XNUMERIC-+--)-' | | .-LAXNESTED-------------------------. | +-+-NOLAXNESTED--+------------------+-+----------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-LAXPACKAGE---. | +-+-NOLAXPACKAGE-+-------------------------------------------+ | .-LAXPARMS-------------------------. | +-+-NOLAXPARMS--+------------------+-+-----------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-LAXPUNC---. | +-+-NOLAXPUNC-+----------------------------------------------+ | .-LAXQUAL----------------------------------------------. | +-+-NOLAXQUAL--+------------------+--+-----------------+-+---+ | | .-LOOSE--. | | .-ALL---. | | | '-(--+-STRICT-+--)-' '-(--+-FORCE-+--)-' | | .-LAXRETURN---. | +-+-NOLAXRETURN-+--------------------------------------------+ | .-NOLAXSCALE--+------------------+--+------------------+-. | | | | .-LOOSE--. | | .-ALL----. | | | | | '-(--+-STRICT-+--)-' '-(--+-SOURCE-+--)-' | | +-+-LAXSCALE-----------------------------------------------+-+ | .-LAXSEMI---. | +-+-NOLAXSEMI-+----------------------------------------------+ | .-LAXSTG---. | +-+-NOLAXSTG-+-----------------------------------------------+ | .-LAXSTMT-------------------------. | +-+-NOLAXSTMT--+------------------+-+------------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-NOLAXSTRZ-. | '-+-LAXSTRZ---+----------------------------------------------' .-,-------------------------------------------------------------. V .-NOMULTICLOSE-. | |--RULES--(----+-+-MULTICLOSE---+------------------------------------------+-+--)--| | .-MULTIENTRY-------------------------. | +-+-NOMULTIENTRY--+------------------+-+--------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-MULTIEXIT-------------------------. | +-+-NOMULTIEXIT--+------------------+-+---------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-MULTISEMI-------------------------. | +-+-NOMULTISEMI--+------------------+-+---------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-PADDING-----------------------------------------------. | +-+-NOPADDING--+------------------+--+------------------+-+-+ | | .-ALL----. | | .-LOOSE--. | | | '-(--+-SOURCE-+--)-' '-(--+-STRICT-+--)-' | | .-PROCENDONLY-------------------------. | +-+-NOPROCENDONLY--+------------------+-+-------------------+ | | .-ALL----. | | | '-(--+-SOURCE-+--)-' | | .-RECURSIVE---. | +-+-NORECURSIVE-+-------------------------------------------+ | .-SELFASSIGN---. | +-+-NOSELFASSIGN-+------------------------------------------+ | .-UNREF---------------------. | | | .-ALL----. | | +-+-NOUNREF--(--+-SOURCE-+--)-+-----------------------------+ | .-UNREFBASED---------------------. | | | .-ALL----. | | +-+-NOUNREFBASED--(--+-SOURCE-+--)-+------------------------+ | .-UNREFCTL---------------------. | | | .-ALL----. | | +-+-NOUNREFCTL--(--+-SOURCE-+--)-+--------------------------+ | .-UNREFDEFINED---------------------. | | | .-ALL----. | | +-+-NOUNREFDEFINED--(--+-SOURCE-+--)-+----------------------+ | .-UNREFENTRY---------------------. | | | .-ALL----. | | +-+-NOUNREFENTRY--(--+-SOURCE-+--)-+------------------------+ | .-UNREFDEFFILE---------------------. | | | .-ALL----. | | +-+-NOUNREFDEFFILE--(--+-SOURCE-+--)-+----------------------+ | .-UNREFSTATIC---------------------. | | | .-ALL----. | | +-+-NOUNREFSTATIC--(--+-SOURCE-+--)-+-----------------------+ | .-YY---. | '-+-NOYY-+--------------------------------------------------'
Also, under RULES(ANS), the following errors, which the old compilers ignored, produce E-level messages:
The default is RULES(IBM).
The default is RULES(BYNAME).
If you specify RULES(COMPLEX), the compiler will not flag such statements.
The default is RULES(COMPLEX). When you specify RULES(NOCOMPLEX), the default is ALL.
Specifying CONTROLLED causes the compiler not to flag the use of the CONTROLLED attribute.
The default is RULES(CONTROLLED).
Specifying RULES(DECSIZE) might cause the compiler to produce many messages because when SIZE is disabled, any statement of the form X = X + 1 will be flagged if X is FIXED DECIMAL.
The default is RULES(NODECSIZE).
This option can be useful in enforcing that SELECT statements be used rather than a series of nested IF-THEN-ELSE statements.
The RULES(NOELSEIF) compiler option now also flags ELSE statements immediately followed by an IF statement that is enclosed in a simple DO-END.
The default is RULES(ELSEIF).
The default is RULES(EVENDEC).
If you specify RULES(NOGLOBAL), the compiler will not flag such usage.
The default is RULES(GLOBAL). When you specify RULES(NOGLOBAL), the default is ALL.
The default is RULES(GLOBALDO).
Specifying NOGOTO(LOOSE) causes the compiler to flag any GOTO statement to a label constant unless the GOTO is exiting an ON-unit or unless the target label constant is in the same block as the GOTO statement.
Specifying NOGOTO(LOOSEFORWARD) causes the compiler to flag any GOTO statement to a label constant unless the GOTO is exiting an ON-unit or unless the target label constant is in the same block as the GOTO statement and comes after the GOTO statement.
The default is RULES(GOTO). When you specify RULES(NOGOTO), the default is STRICT.
The default is RULES(NOLAXBIF).
Specifying RULES(NOLAXCONV) causes the compiler to flag arithmetic expressions where an operand does not have arithmetic type.
The default is RULES(LAXCONV). When you specify RULES(NOLAXCONV), the default is ALL.
dcl a bit(8) ctl;
alloc a;
alloc a bit(16);
dcl b bit(n) ctl;
dcl n fixed bin(31) init(8);
alloc b;
alloc b bit(16);
The default is RULES(NOLAXCTL).
The default is RULES(NOLAXDCL).
The default is RULES(NOLAXDEF).
The default is RULES(LAXENTRY). When you specify RULES(NOLAXENTRY), the default is STRICT.
If you specify LAXEXPORTS, the compiler will not flag such compilation units.
The default is RULES(LAXEXPORTS).
The default is RULES(LAXFIELDS).
dcl i fixed bin;
dcl b bit(8);
.
.
.
if i then …
if b then …
The default is RULES(NOLAXIF).
The default is RULES(LAXINOUT).
The default is RULES(LAXINTERFACE).
For instance, if A1 is declared as ENTRY(CHAR(8)) and A2 as ENTRY(POINTER) VARIABLE, under RULES(NOLAXLINK) the compiler will flag an attempt to assign A1 to A2.
For instance, if A3 is declared as ENTRY RETURNS(FIXED BIN(31)) and A4 as an ENTRY VARIABLE without the RETURNS attribute, under RULES(NOLAXLINK) the compiler will flag an attempt to assign A3 to A4.
For instance, if A5 is declared as ENTRY OPTIONS(ASM) and A6 as an ENTRY VARIABLE without the OPTIONS attribute, under RULES(NOLAXLINK) the compiler will flag an attempt to assign A5 to A6. This is because the OPTIONS(ASM) in the declare of A5 implies that A5 has LINKAGE(SYSTEM)), and in contrast, because A6 has no OPTIONS attribute, it will have LINKAGE(OPTLINK) by default).
The default is RULES(LAXLINK).
If the NOLAXMARGINS and STMT options are used together with one of the preprocessors, any statements that would be flagged because of the NOLAXMARGINS option will be reported as statement zero (because statement numbering occurs only after all the preprocessors are finished, but the detection of text outside the margins occurs as soon as the source is read).
The default is RULES(LAXMARGINS). When you specify RULES(NOLAXMARGINS), the default is ALL.
Specifying RULES(NOLAXNESTED) causes the compiler to flag any executable code in a procedure that follows any subprocedures.
The default is RULES(LAXNESTED). When you specify RULES(NOLAXNESTED), the default is ALL.
If you specify LAXPACKAGE, the compiler will not flag such compilation units.
The default is RULES(LAXPACKAGE).
If you specify RULES(NOLAXPARMS), the compiler will not flag such statements.
The default is RULES(LAXPARMS). When you specify RULES(NOLAXPARMS), the default is ALL.
For instance, given the statement I = (1 * (2);, the compiler assumes that a closing right parenthesis is meant before the semicolon. Under RULES(NOLAXPUNC), this statement will be flagged with an E-level message; otherwise, it will be flagged with a W-level message.
The default is RULES(LAXPUNC).
dcl
1 a,
2 b,
3 b fixed bin,
3 c fixed bin;
c = 11; /* would be flagged */
b.c = 13; /* would not be flagged */
a.c = 17; /* would not be flagged */
dcl
1 a,
2 b,
3 b fixed bin,
3 c fixed bin;
c = 11; /* would be flagged */
b.c = 13; /* would be flagged */
a.c = 17; /* would not be flagged */
The default is RULES(LAXQUAL). When you specify RULES(NOLAXQUAL), LOOSE and ALL are defaults.
ERROR will also be raised if the code falls through to the END statement in a PROCEDURE with the RETURNS attribute.
The default is RULES(LAXRETURN).
It also causes the compiler to flag ROUND(x,p) when p < 0.
The message issued when the compiler flags ROUND(x,p) is different from that issued when the compiler flags the FIXED BIN(p,q) or FIXED DEC(p,q) declaration. Therefore, you can use the EXIT option to suppress the message issued when ROUND(x,p) is flagged and keep the message for other questionable declarations.
The default is RULES(NOLAXSCALE). When you specify RULES(NOLAXSCALE), LOOSE and ALL are defaults.
The default is RULES(LAXSEMI).
Note that even with NOLAXSTG specified, if B has subscripts, no IBM2402I E-level message will be produced.
The compiler would already flag this kind of problem if B were in AUTOMATIC or STATIC storage, but it does not, by default, flag this when B is a parameter (because some programmers declare B with placeholder attributes that do not describe the actual argument). For situations where parameter and argument declarations match (or should match), specifying RULES(NOLAXSTG) can help detect more storage overlay problems.
The default is RULES(LAXSTG).
Additionally, NOLAXSTMT accepts EXCEPT with a (possibly empty) list of keywords that are not be flagged when a second statement on a line begins with one of these keywords. For example, this can allow DO; to appear on the same line as an IF … THEN statement.
The following keywords are allowed in EXCEPT:
allocate |
halt |
The default is RULES(LAXSTMT). When you specify RULES(NOLAXSTMT), the default is ALL.
The default is RULES(NOLAXSTRZ).
The default is RULES(NOMULTICLOSE).
The default is RULES(MULTIENTRY). When you specify RULES(NOMULTIENTRY), the default sub-suboption is ALL.
The default is RULES(MULTIEXIT). When you specify RULES(NOMULTIEXIT), the default sub-suboption is ALL.
The default is RULES(MULTISEMI). When you specify RULES(NOMULTISEMI), the default sub-suboption is ALL.
The default is RULES(PADDING). When you specify RULES(NOPADDING), the default sub-suboption are ALL and LOOSE.
The default is RULES(PROCENDONLY). When you specify RULES(NOPROCENDONLY), the default sub-suboption is ALL.
Specifying RECURSIVE causes the compiler not to flag the use of the RECURSIVE attribute or any procedure that directly calls itself.
The default is RULES(RECURSIVE).
The default is RULES(SELFASSIGN).
The default is RULES(UNREF). When you specify RULES(NOUNREF), the default sub-suboption is ALL.
The default is RULES(UNREFBASED). When you specify RULES(NOUNREFBASED), the default sub-suboption is ALL.
The default is RULES(UNREFCTL). When you specify RULES(NOUNREFCTL), the default sub-suboption is ALL.
The default is RULES(UNREFDEFINED). When you specify RULES(UNREFDEFINED), the default sub-suboption is ALL.
The default is RULES(UNREFENTRY). When you specify RULES(NOUNREFENTRY), the default sub-suboption is ALL.
The default is RULES(UNREFFILE). When you specify RULES(NOUNREFFILE), the default sub-suboption is ALL.
The default is RULES(UNREFSTATIC). When you specify RULES(NOUNREFSTATIC), the default sub-suboption is ALL.
The default is RULES(YY).
Default: RULES (IBM BYNAME COMPLEX CONTROLLED NODECSIZE EVENDEC ELSEIF GLOBAL GLOBALDO GOTO NOLAXBIF LAXCONV NOLAXCTL NOLAXDCL NOLAXDEF LAXENTRY LAXEXPORTS NOLAXFIELDS NOLAXIF LAXINOUT LAXINTERFACE LAXLINK LAXNESTED LAXPACKAGE LAXPARMS LAXPUNC LAXMARGINS(STRICT) LAXQUAL LAXRETURN NOLAXSCALE LAXSEMI LAXSTG LAXSTMT NOLAXSTRZ NOMULTICLOSE MULTIENTRY MULTIEXIT MULTISEMI PADDING PROCENDONLY RECURSIVE SELFASSIGN UNREF UNREFBASED UNREFCTL UNREFDEFINED UNREFENTRY UNREFFILE UNREFSTATIC YY )