I am reading about declarators in C99 ISO Standard and I am struggling to understand the following passage:
5 If, in the declaration ”
T D1
”,D1
has the formidentifier
then the type specified for ident is
T
.6 If, in the declaration “
T D1
”,D1
has the form
( D )
then ident has the type specified by the declaration “
T D
”. Thus, a declarator in parentheses is identical to the unparenthesized declarator, but the binding of complicated declarators may be altered by parentheses.
You omitted an important previous paragraph:
4 In the following subclauses, consider a declaration
T D1
where
T
contains the declaration specifiers that specify a type T (such asint
) andD1
is a declarator that contains an identifier ident. The type specified for the identifier ident in the various forms of declarator is described inductively using this notation.
So, when we get to paragraphs 5 and 6, we know the declaration we are considering contains within it some identifier which we label ident. E.g., in int foo(void)
, ident is foo
.
Paragraph 5 says that if the declaration “T
D1
” is just ”T
ident”, it declares ident to be of type T
.
Paragraph 6 says that if the declaration “T
D1
” is just ”T
(
ident)
”, it also declares ident to be of type T
.
These are just establishing the base cases for a recursive specification of declaration. Clause 6.7.5.1 goes on to say that if the declaration “T
D1
” is ”T
*
some-qualifiers D
” and the same declaration without the *
and the qualifiers, ”T
D
” would declare ident to be “some-derived-type T
” (like “array of T
” or “pointer to T
”), then the declaration with the *
and the qualifiers declares ident* to be “some-derived-type some-qualifiers pointer to T
”.
For example, int x[3]
declares x
to be “array of 3 int
”, so this rule in 6.7.5.1 tells us that “int * const x[3]
declares x
to be “array of 3 const pointer to int
”—it takes the “array of 3” that must have been derived previously and appends “const pointer to” to it.
Similarly, clauses 6.7.5.2 and 6.7.5.3 tell us to append array and function types to declarators with brackets (for subscripts) and postfix parentheses.