Valid-declor
Validate a declarator.
- Signature
(valid-declor declor fundef-params-p type table ienv)
→
(mv erp new-declor new-fundef-params-p
new-type ident return-types new-table)
- Arguments
- declor — Guard (declorp declor).
- fundef-params-p — Guard (booleanp fundef-params-p).
- type — Guard (typep type).
- table — Guard (valid-tablep table).
- ienv — Guard (ienvp ienv).
- Returns
- new-declor — Type (declorp new-declor).
- new-fundef-params-p — Type (booleanp new-fundef-params-p).
- new-type — Type (typep new-type).
- ident — Type (identp ident).
- return-types — Type (type-setp return-types).
- new-table — Type (valid-tablep new-table).
This function is called after validating
a list of declaration specifiers,
or a list of specifiers and qualifiers:
if the validation of those lists is successful,
they determine a type, which the declarator can further refine:
we pass that type as input to this validation function,
which returns the possibly refined type,
along with the identifier being declared.
This function is also called recursively,
since declarators and direct declarators are mutually recursive.
The fundef-params-p flag is t
when this function is called
to validate the declarator of a function definition,
and only when the parameters of the function have not been validated yet.
Its new value fundef-params-p, returned as result,
stays t if the parameters of the function
have still not been validated yet,
because they are not found in this declarator;
otherwise, its new value is nil.
If the input fundef-params-p is nil,
then new-fundef-params-p is nil as well.
The exact handling of this flag,
and the exact treatment of the parameters of function declarations,
are explained in the code that actually makes use of the flag.
In our currently approximate type system,
we do not validate type qualifiers, or attributes.
So the only role of the pointers component of declor
is to refine the type passed as input into the pointer type
[C:6.7.6.1/1].
This resulting type is then passed to
the function to validate the direct declarator that follows.
We also pass the fundef-params-p flag to valid-dirdeclor,
and relay the new-fundef-params-p output.
The reason is that, after peeling off the pointers,
which refine the return result of the function,
the direct declarator is still expected to be for a function,
and we have not validated the parameters yet.