[J3] conditional-arg and the handling of additional (expr) parens

Robert Corbett rpcorbett at att.net
Tue Mar 10 20:58:36 UTC 2026


A conditional argument cannot be enclosed in parentheses.  The syntax of the language does not allow it.  The parentheses that are part of the conditional argument are allowed and required.  The syntax rules allow for an expression to be enclosed in parentheses, which produces a primary.  The syntax rules do not allow a conditional argument to be enclosed in parentheses.

Parentheses have several effects in Fortran.  If a data pointer is enclosed in parentheses, the resulting primary is neither a pointer nor a variable.

A conforming processor is required to be capable of diagnosing an appearance of the token .NIL. outside of a conditional argument.

Constraint C1535 is provided to resolve possible syntactic ambiguities.

Bob Corbett

> On Mar 10, 2026, at 12:48 PM, Johnson, Ted via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> 
> I'm trying to understand the impact of adding some wrapping parens to create an expr, within the context of conditional arguments.
> 
> I believe something like this should be rejected - attempting to turn .NIL. into an expr, or trying to turn the whole conditional-arg into an expr. Yes, or no?
> 
> call foo( ((cond ? (X) : (.NIL.))) )
> 
> I don't see how ((.NIL.)) could ever be correct based on 25-007r1.
> 
> Also I wanted to see if "C1535 An actual-arg that is an expr shall not be a variable or a conditional-arg" was intended to prevent converting a whole conditional-arg into an expr.
> 
> Since a bare ((.NIL.)) doesn't appear to be valid , I would assume call foo( (( .true. ? .NIL. : X)) ) hits up against C1535 as well. If not, why?
> 
> Thanks.
> 
> -ted
> 
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20260310/39464c20/attachment.htm>


More information about the J3 mailing list