decl_attrs.h (1372B)
1 #ifndef KIT_DECL_ATTRS_H 2 #define KIT_DECL_ATTRS_H 3 4 #include "decl/decl.h" 5 #include "parse/attr.h" 6 7 /* Decodes a parser-produced Attr* list onto a Decl. Walks the chain and 8 * applies every honored attribute (see doc/ATTRIBUTE.md "Phase 2"): 9 * 10 * packed — N/A here (record-level; see Type.rec.packed) 11 * aligned(N) — Decl.align = max(Decl.align, N) 12 * section("s") — interns the section name and stores Decl.section_id 13 * used — Decl.flags |= DF_USED 14 * noreturn — Decl.flags |= DF_NORETURN 15 * alias("t") — Decl.alias_target = intern("t") 16 * weak — Decl.flags |= DF_WEAK 17 * visibility(s)— Decl.visibility = SV_* 18 * always_inline / noinline / gnu_inline — Decl.flags |= DF_* 19 * 20 * Unknown / non-honored attributes (deprecated, format, nonnull, ...) 21 * are silently skipped — they were validated for argument shape during 22 * parsing and have no Decl-side effect in Phase 2. 23 * 24 * `attrs` may be NULL; `out` must be non-NULL. Idempotent: applying a 25 * list twice produces the same Decl state. Phase 2 callers invoke this 26 * once, between filling out the bulk Decl fields and decl_declare(). 27 * DeclTable* is reserved for declaration-table context; attributes do not 28 * reach below the public frontend/codegen boundary. */ 29 void attr_list_to_decl(Compiler*, DeclTable*, const Attr* attrs, Decl* out); 30 31 #endif