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, the result is always SIGNED.
- Even when you add, multiply, or divide two UNSIGNED FIXED BIN
operands, the result has the SIGNED attribute.
- Even when you apply the MOD or REM built-in functions to two
UNSIGNED FIXED BIN operands, the result has the SIGNED 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.
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.
- GOTO|NOGOTO
- Specifying NOGOTO causes all GOTO statements to be flagged
except for those out of BEGIN blocks.
- 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 will cause the compiler to flag all unprototyped entry declarations,
i.e. 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.
- 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 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 fixed bin,
2 c fixed bin;
c = 15; /* would be flagged */
a.c = 15; /* would not be flagged */
- 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.
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
- NOMULTICLOSE causes the compiler to flag all statements that
force the closure of multiple groups of statement with an E-level
message.
- 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.