pub enum Decl {
Error,
Var {
specs: DeclSpecsId,
declarators: InitDeclaratorList,
},
Function {
specs: DeclSpecsId,
declarator: DeclaratorId,
params: DeclList,
body: StmtId,
},
StaticAssert {
cond: ExprId,
message: Option<StrId>,
},
Asm(AsmId),
Attributes(AttrList),
}Expand description
One declaration.
A declaration, not a declarator: int a, *b = 0; is one Decl::Var holding one specifier
list and two InitDeclarators. Keeping the grouping means a diagnostic can point at the
specifiers that both declarators share, and it means the printer puts the source back
together the way it was written.
Twenty-four bytes, set by Decl::Function.
Variants§
Error
A parse that did not work out. Poisoned, as Expr::Error is.
Var
Specifiers and zero or more declarators.
Zero is not a mistake: struct S { int x; }; declares a tag and nothing else, and
int; is the same shape with a diagnostic attached.
Fields
specs: DeclSpecsIdWhat the declaration says before the first declarator.
declarators: InitDeclaratorListThe declarators, each with its own initializer.
Function
A function definition, which is the one declaration with a body.
Attributes written after the declarator go into specs rather than onto the declarator,
because a definition has exactly one declarator and everything on it appertains to the
same declaration however it was written.
Fields
specs: DeclSpecsIdThe specifiers.
declarator: DeclaratorIdThe declarator, whose outermost derivation is the function one.
StaticAssert
static_assert(cond) or static_assert(cond, "message").
Fields
Asm(AsmId)
asm("...") at file scope.
Attributes(AttrList)
[[...]]; on its own, which C23 allows and which appertains to nothing.