Question
6.7.5 introduces a new use of the static keyword. A new keyword should be used instead.
This use of static can only occur in function parameter declaration. If we examine the syntax carefully, static assignment-expression taken together inside [ and ] really plays the role of a type qualifier qualifying a pointer. This means the assignment-expression should only be allowed to follow immediately after the keyword static (when static is present), with no other type qualifiers allowed in between. Also, a new keyword should be used to make the meaning clear.Suggested Correction
direct_declarator :
identifier
( declarator )
direct-declarator [ type-qualifier-listassignment-expression ]
direct-declarator [ __at_least assignment-expression type-qualifier-list]
direct-declarator [ type-qualifier-list__at_least assignment-expression ]
[#1] In addition to optional type qualifiers and the keyword __at_least, the [ and ] may delimit an expression or *. If they delimit an expression (which specifies the size of an array), the expression shall have an integer type. If the expression is a constant expression, it shall have a value greater than zero. The element type shall not be an incomplete or function type. The optional type qualifiers and the keyword __at_least shall appear only in a declaration of a function parameter with an array type, and then only in the outermost array type derivation.Change 6.7.5.2p3 to (i.e. the three occurences of static to __at_least, and bind __at_least with assignment-expr in the syntax) :
D[ type-qualifier-list-opt assignment-expr-opt ]
D[ __at_least assignment-expr type-qualifier-list-opt ]
D[ type-qualifier-list __at_least assignment-expr ]
D[ type-qualifier-list-opt * ]
and the type specified for ident in the declaration "T D" is "derived-declarator-type-list T", then the type specified for ident is "derived-declarator-type-list array of T".121) (See 6.7.5.3 for the meaning of the optional type qualifiers and the keyword __at_least.)Change 6.7.5.3p7 to (i.e. static to __at_least) :
[#7] A declaration of a parameter as "array of type" shall be adjusted to "qualified pointer to type", where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword __at_least ...Change 6.7.5.3p21 to (i.e. static to __at_least) :
[#21] EXAMPLE 5 The following are all compatible function prototype declarators.as are:
double maximum(int n, int m, double a[n][m]);double maximum(int n, int m, double a[*][*]);
double maximum(int n, int m, double a[ ][*]);
double maximum(int n, int m, double a[ ][m]);
Change A.1.2 to add keyword :void f(double (* restrict a)[5]);
void f(double a[restrict][5]);
void f(double a[restrict 3][5]);
void f(double a[restrict __at_least 3][5]);
...
__at_leastExplanation of the change
Conceptually,'__at_least assignment-expression' is a type qualifier. Even though we do not treat it as such in C9X, the potential is there for future enhancement of the language. Therefore we should not interfer with possible future changes in this respect. The following example illustrates the point.double a[restrict __at_least 3] /* ok */
double a[__at_least 3 restrict] /* ok */
double a[__at_least restrict 3] /* not ok */
int * __at_least(10) pwhich declares a pointer pointing to the first of a sequence of 10 integers in memory. (The parentheses are used for clarity.) The clumsy description in 6.7.5.3p7 become unecessary. Note that the current static syntax prevents us from writing the equivalent pointer declaration for an array parameter declaration.