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.
- IBM | ANS
- Under the IBM suboption:
- For operations requiring string data, data with the BINARY attribute
is converted to BIT.
- Conversions in arithmetic operations or comparisons occur as described
in the PL/I Language Reference.
- Conversions for the ADD, DIVIDE, MULTIPLY, and SUBTRACT built-in
functions occur as described in the PL/I Language Reference except that operations specified as scaled fixed
binary are evaluated as scaled fixed decimal.
- Nonzero scale factors are permitted in FIXED BIN declares.
- If the result of any precision-handling built-in function (ADD,
BINARY, etc.) has FIXED BIN attributes, the specified or implied scale
factor can be nonzero.
- Even if all arguments to the MAX
or MIN built-in functions are UNSIGNED FIXED BIN, all the arguments
are converted to SIGNED, the function is evaluated with these converted
arguments, and the result is always SIGNED.
- Even when you add, multiply, or
divide two UNSIGNED FIXED BIN operands, all the operands are converted
to SIGNED, the operation is evaluated with these converted arguments,
and the result has the SIGNED attribute.
- Even when you apply the MOD or
REM built-in functions to two UNSIGNED FIXED BIN operands, all the
arguments are converted to SIGNED, the function is evaluated with
these converted arguments, and the result has the SIGNED attribute.
- Declaring a variable with the OPTIONS
attribute implies the ENTRY attribute.
Under the ANS suboption:
- For operations requiring string data, data with the BINARY attribute
is converted to CHARACTER.
- Conversions in arithmetic operations or comparisons occur as described
in the PL/I Language Reference.
- Conversions for the ADD, DIVIDE, MULTIPLY, and SUBTRACT built-in
functions occur as described in the PL/I Language Reference.
- Nonzero scale factors are not permitted
in FIXED BIN declares.
- If the result of any precision-handling built-in function (ADD,
BINARY, etc.) has FIXED BIN attributes, the specified or implied scale
factor must be zero.
- If all arguments to the MAX or MIN built-in functions are UNSIGNED
FIXED BIN, the result is UNSIGNED.
- When you add, multiply or divide two UNSIGNED FIXED BIN operands,
the result has the UNSIGNED attribute.
- When you apply the MOD or REM built-in functions to two UNSIGNED
FIXED BIN operands, the result has the UNSIGNED attribute.
- Declaring a variable with the OPTIONS
attribute does not imply the ENTRY attribute.
Also, under RULES(ANS), the following errors, which
the old compilers ignored, will produce E-level messages:
- Specifying a string constant as the argument to the STRING built-in
- Giving too many asterisks as subscripts in an array reference
- Qualifying a CONTROLLED variable with a POINTER reference (as
if the CONTROLLED variable were BASED)
- BYNAME | NOBYNAME
- Specifying NOBYNAME causes the compiler to flag all BYNAME assignments
with an E-level message.
- DECSIZE | NODECSIZE
- Specifying DECSIZE causes the compiler to flag any assignment
of a FIXED DECIMAL expression to a FIXED DECIMAL variable when the
SIZE condition is disabled if the SIZE condition could be raised by
the assignment.
Specifying RULES(DECSIZE) may cause the compiler
to produce a large number of messages since if SIZE is disabled, then
any statement of the form X = X + 1 will be flagged if X is FIXED
DECIMAL.
- ELSEIF | NOELSEIF
- Specifying NOELSEIF causes the compiler to flag any ELSE statement
that is immediately followed by an IF statement and suggest that it
be rewritten as a SELECT statement.
This option can be useful in
enforcing that SELECT statements be used rather than a series of nested
IF-THEN-ELSE statements.
- EVENDEC | NOEVENDEC
- Specifying NOEVENDEC causes the compiler to flag any FIXED DECIMAL
declaration that specifies an even precision.
- GLOBALDO | NOGLOBALDO
- Specifying NOGLOBALDO instructs the compiler to flag all DO loops with
control variables that are declared in a parent block.
- GOTO | NOGOTO
- 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(STRICT)
causes the compiler to flag any GOTO statement to a label constant
unless the GOTO is exiting an ON-unit.
- LAXBIF | NOLAXBIF
- Specifying LAXBIF causes the compiler to build a contextual
declaration for built-in functions, such as NULL, even when used without
an empty parameter list.
- LAXCTL | NOLAXCTL
- Specifying LAXCTL allows a CONTROLLED variable to be declared
with a constant extent and yet to be allocated with a differing extent.
NOLAXCTL requires that if a CONTROLLED variable is to be allocated
with a varying extent, then that extent must be specified as an asterisk
or as a non-constant expression.
The following code is illegal
under NOLAXCTL:
dcl a bit(8) ctl;
alloc a;
alloc a bit(16);
But this code would still be valid
under NOLAXCTL:
dcl b bit(n) ctl;
dcl n fixed bin(31) init(8);
alloc b;
alloc b bit(16);
- LAXDCL | NOLAXDCL
- Specifying LAXDCL allows implicit declarations. NOLAXDCL disallows
all implicit and contextual declarations except for BUILTINs and for
files SYSIN and SYSPRINT.
- LAXDEF | NOLAXDEF
- Specifying LAXDEF allows so-called illegal defining to be accepted
without any compiler messages (rather than the E-level messages that
the compiler would usually produce).
- LAXENTRY | NOLAXENTRY
- Specifying LAXENTRY allows unprototyped entry declarations.
Specifying NOLAXENTRY causes the compiler to flag all unprototyped
entry declarations, that is, all ENTRY declares that do not specify a
parameter list. Note that this would mean that if an ENTRY should
have no parameters, it should be declared as ENTRY() rather than simply
as ENTRY.
- STRICT
- Specifying RULES(NOLAXENTRY(STRICT)) causes the compiler to
flag unprototyped entry declarations that have the OPTIONS(ASM) attribute.
- LOOSE
- Specifying RULES(NOLAXENTRY(LOOSE)) causes the compiler not
to flag unprototyped entry declarations that have the OPTIONS(ASM)
attribute.
RULES(LAXENTRY) is the default. When you specify
NOLAXENTRY, STRICT is the default.
- LAXIF | NOLAXIF
- Specifying RULES(NOLAXIF)
will cause the compiler to flag any IF, WHILE, UNTIL, and WHEN clauses
that do not have the attributes BIT(1) NONVARYING.
The following would all be flagged under NOLAXIF:
dcl i fixed bin;
dcl b bit(8);
.
.
.
if i then ...
if b then ...
- LAXINOUT | NOLAXINOUT
- Specifying NOLAXINOUT causes the compiler to assume that all
ASSIGNABLE BYADDR parameters are input (and possibly output) parameters
and hence to issue a warning if it thinks such a parameter has not
been initialized.
- LAXLINK | NOLAXLINK
- Specifying NOLAXLINK causes the
compiler to flag any assign or compare of two ENTRY variables or constants
if any of the following do not match:
- the parameter description lists
For instance if A1 is declared
as ENTRY(CHAR(8)) and A2 as ENTRY(POINTER) VARIABLE, then under RULES(NOLAXLINK),
the compiler would flag an attempt to assign A1 to A2.
- the RETURNS attribute
For instance if A3 is declared as ENTRY
RETURNS(FIXED BIN(31)) and A4 as an ENTRY VARIABLE without the RETURNS
attribute, then under RULES(NOLAXLINK), the compiler would flag an
attempt to assign A3 to A4.
- the LINKAGE and other OPTIONS suboptions
For instance if A5
is declared as ENTRY OPTIONS(ASM) and A6 as an ENTRY VARIABLE without
the OPTIONS attribute, then under RULES(NOLAXLINK), the compiler would
flag an attempt to assign A5 to A6 (since the OPTIONS(ASM) in the
declare of A5 implies that A5 has LINKAGE(SYSTEM)) while since A6
has no OPTIONS attribute, it will have LINKAGE(OPTLINK) by default).
.
- LAXMARGINS | NOLAXMARGINS
- Specifying NOLAXMARGINS causes
the compiler to flag, depending on the setting of the STRICT and XNUMERIC
suboption, lines containing non-blank characters after the right margin.
This can be useful in detecting code, such as a closing comment, that
has accidentally been pushed out into the right margin.
If the NOLAXMARGINS and STMT options are used together
with one of the preprocessors, then any statements that would be flagged
because of the NOLAXMARGINS option will be reported as statement zero
(since 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).
- STRICT
- Under the STRICT suboption, the compiler will flag any line
containing non-blank characters after the right margin
- XNUMERIC
- Under the XNUMERIC suboption, the compiler will flag any line
containing non-blank characters after the right margin except if the
right margin is column 72 and columns 73 through 80 all contain numeric
digits
- LAXPUNC | NOLAXPUNC
- Specifying NOLAXPUNC causes the compiler to flag with an E-level
message any place where it assumes punctuation that is missing.
For
instance, given the statement "I = (1 * (2);", the compiler assumes
that a closing right parenthesis was meant before the semicolon. Under
RULES(NOLAXPUNC), this statement would be flagged with an E-level
message; otherwise it would be flagged with a W-level message.
- LAXQUAL | NOLAXQUAL
- Specifying NOLAXQUAL(LOOSE) causes
the compiler to flag any reference to structure members that are not
level 1 and are not dot qualified. Consider the following example:
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 */
Specifying NOLAXQUAL(STRICT)
causes the compiler to flag any reference to structure members that
do not include the level-1 name. Consider the following example:
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 */
- LAXRETURN | NOLAXRETURN
- Specifying NOLAXRETURN causes the compiler to generate code
to raise the ERROR condition when a RETURN statement is used in either
of the following ways:
- With an expression in a procedure that is coded
without the RETURNS option
- Without an expression in a procedure that is
coded with the RETURNS option
RULES(LAXRETURN) is the default.
- LAXSCALE | NOLAXSCALE
- Specifying NOLAXSCALE causes the compiler to flag any FIXED
BIN(p,q) or FIXED DEC(p,q) declare where q < 0 or
p < q.
- LAXSEMI | NOLAXSEMI
- Specifying NOLAXSEMI causes the compiler to flag any semicolons
appearing inside comments.
- LAXSTG | NOLAXSTG
- Specifying NOLAXSTG causes the compiler to flag declares where
a variable A is declared as BASED on ADDR(B) and STG(A) > STG(B) even
(and this is the key part) if B is a parameter.
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 (since
some customers declare B with placeholder attributes that do not describe
the actual argument). For those customers whose parameter and argument
declares match (or should match), specifying RULES(NOLAXSTG) may help
detect more storage overlay problems.
- LAXSTRZ | NOLAXSTRZ
- Specifying LAXSTRZ causes the compiler not to flag any bit or
character variable that is initialized to or assigned a constant value
that is too long if the excess bits are all zeros (or if the excess
characters are all blank).
- MULTICLOSE | NOMULTICLOSE
- Specifying NOMULTICLOSE causes the compiler to flag all statements that
force the closure of multiple groups of statement with an E-level
message.
- PADDING | NOPADDING
- Specifying NOPADDING
causes the compiler to flag all structures that contain padding.
- PROCENDONLY | NOPROCENDONLY
- Specifying NOPROCENDONLY causes any END statement closing a
PROCEDURE to be flagged if the END statement does not name the PROCEDURE,
that is, if the END keyword is immediately followed by a semicolon.
- SELFASSIGN | NOSELFASSIGN
- Specifying NOSELFASSIGN causes the compiler to flag all assignments
where the source and the target are the same.
RULES(SELFASSIGN)
is the default.
- STOP | NOSTOP
- Specifying NOSTOP causes all STOP and EXIT statements to be
flagged.
- UNREF | NOUNREF
- Specifying NOUNREF causes the compiler to flag any level-1 AUTOMATIC
variable which is not referenced and which, if it is a structure or
union, contains no subelement which is referenced.