diff --git a/drafts/25-xxx-specifications.txt b/drafts/25-xxx-specifications.txt index 00b205c..0673a47 100644 --- a/drafts/25-xxx-specifications.txt +++ b/drafts/25-xxx-specifications.txt @@ -223,6 +223,11 @@ syntax below, we denote these as just "token-list" or "replacement-list". +di00. The directives listed in di01-di08 are only recognized as such + if the token immediately following the '#' introducing a + directive line exactly matches one of the standard directive + names ('define', 'if', 'pragma', etc.). + di01. The '#define' object-like macro directive di02. The '#define' function-like macro directive @@ -232,7 +237,7 @@ di03. The '#undef' directive di04. The '#include' directive di05. The '#if', '#ifdef', '#ifndef', '#elif', '#elifdef', - '#elifndef', '#else', '#endif' directives + '#elifndef', '#else', '#endif' conditional directives di06. The '#error' and '#warning' directives @@ -316,7 +321,7 @@ df04. The identifier-list is a comma-separated list of ID tokens. df06. No identifier may appear more than once in the identifier-list. df08. The identifier names in the identifier-list define macro "parameters" that affect - macro expansion of the replacement list. (See the section "Macro recognition and + macro expansion of the replacement list. (See the section "Macro recognition and expansion" for the semantics of function-like macro expansion.) df10. The replacement-list may be the empty sequence of tokens. @@ -413,22 +418,146 @@ in28. Unlike INCLUDE lines (see the section on "INCLUDE lines"), the #include directive is not prohibited from including the same source file at a deeper level of nesting. + 3.5 The '#if', '#ifdef', '#ifndef', '#elif', '#elifdef', - '#elifndef', '#else', '#endif' directives + '#elifndef', '#else', '#endif' conditional directives --------------------------------------------------------- -Example syntax: +Example syntax (extra spacing for illustration purposes only): + General form: + #endif EOL + #endif EOL + #endif EOL + + Where: + is one of: + #if token-list EOL + #ifdef ID EOL + #ifndef ID EOL + + is zero or more of: + + is one of: + #elif token-list EOL + #elifdef ID EOL + #elifndef ID EOL + + is one of: + #else EOL + + is zero or more of: + directive lines + Fortran comment lines + Fortran source lines 3.5.1 Static semantics specifications --------------------------------------- +------------------------------------- + +if05. A #if, #ifdef, or #ifndef directive signals the start of a list + of conditional directives. + +if15. The list of #elif, #elifdef, and #elifndef directives, and the + #else directive (if present) are part of the same list of + directives introduced by the #if directive. + +if20. The chain of conditional directives ends with the #endif + directive. + +if25. Within a conditional directive list, a #if, #ifdef, or #endif + directive introduces a new list of conditional directives, at a new + nesting level, within the enclosing conditional directive list. + +if30. The conditional directive lists must properly nest. + 3.5.2 Evaluation semantics specifications ----------------------------------------- +ix05. The #ifdef and #ifndef directives are evaluated as if they had been + written "#if defined(ID)" and "#if !defined(ID)" respectively. + (For brevity, the descriptions of #ifdef and #ifndef directives + below are omitted, and assume this transformation.) + +ix10. The #elifdef and #elifndef directives are evaluated as if they had + been written "#elif defined(ID)" and "#elif !defined(ID)" + respectively. + +ix12. In the descriptions below, constructs may be "skipped". + When skipped, + - Conditional directives within the are recognized only + to maintain proper nesting of conditional directives. + - No nested directives in the are processed. + - No macro expansion takes place in directive lines, Fortran + comment lines or source lines in the . + - No skipped lines of any kind in the are made available + subsequent processing by the processor. + +ix14. In the descriptions below, constructs that are not + skipped participate in further preprocessing and processing. + When participating + + - Macros are expanded in Fortran comment lines and source + lines. + - Nested directives in the are processed. + - The resulting Fortran comment lines and source lines + are made available for subsequent processing by the + processor. + +ix15. Before evaluating the token-lists in the and + constructs, macros in the token-lists are processed as described + in the section "Macro recognition and expansion". + +ix20. After expansion, the resulting token list in and + constructs must be able to be parsed as a valid integer expression as + described in the section "Expressions allowed in #if and #elif + directives" static semantics. This expression is called the "controlling + expression" for the directive. + +ix25. The values of controlling expressions in and + constructs are evaluated according to the evaluation semantics + described in the section "Expressions allowed in #if and #elif + directives". + +ix30. If the controlling expression in an evaluates to a + nonzero value, then the contained within that + construct participates in further preprocessing, as describe + above. Subsequent and constructs at the same + level of nesting are skipped. + +ix45. If the controlling expression in an construct + evaluates to a zero value, then the contained within + that construct is skipped. Preprocessing continues + with any constructs at the same level of nesting, as + described below. + +ix50. When the controlling expression in an construct + evaluates to zero, the controlling expressions in each + construct at the same nesting level are evaluated in turn. Those + s whose controlling expression evaluates to zero are + skipped. + +ix55. When the controlling expression in an construct + evaluates to a nonzero value, the contained within that + construct continues to participate in preprocessing. + Subsequent constructs and any remaining + constructs at the same nesting level are skipped. + +ix60. When all controlling expressions in the construct and + constructs evaluate to a zero value and an + construct is present at the same nesting level, the + contained in the construct continues to participate in + preprocessing. + +ix65. When all controlling expressions in the construct and + all constructs evaluate to a zero value and no + construct is present at the same nesting level, then + all s in these constructs are skipped. + + 3.6 The '#error' and '#warning' directives ------------------------------------------