Valid-declor
Validate a declarator.
- Signature
(valid-declor declor fundef-params-p type table ienv)
→
(mv erp new-declor 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
- erp — Type (maybe-msgp erp).
- new-declor — Type (declorp new-declor).
- 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.
The exact handling of this flag,
and the exact treatment of the parameters of function declarations,
are explained in valid-dirdeclor.
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 derived pointer type
[C17: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.
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.