This patch implements Parsing, Semantic analysis, and AST representation for contract attributes as described in P0542R5.
Missing from the implementation:
- CodeGen and library support are on hold until the relevant ABI decisions are made.
- The supporting AST stuff (serialisation etc.) isn't included yet; this patch is large enough as it is.
- Specifying a build level requires a compiler option, which probably requires further discussion.
The rest of it is mostly complete, however there're a few things that I couldn't work out:
- Are contracts allowed on constructors/destructors, or any special member function for that matter? If so, then is MyClass() [[expects: something()]] = default a trivial constructor? I can't seem to find anything relevant in the standard but that seems quite contradictory.
- Are contracts allowed on explicit instantiations? The latest proposal (r5) explicitly forbids it, but that sentence is missing from the current working draft (N4762). Does that mean that it should follow the usual redeclaration rules?
This is dependent on the following patches: