Page MenuHomePhabricator

[C++2a] Parsing and semantic analysis for contracts (P0542R5)
Needs ReviewPublic

Authored by hamzasood on Aug 15 2018, 4:59 AM.



This patch implements Parsing, Semantic analysis, and AST representation for contract attributes as described in P0542R5.

Missing from the implementation:

  1. CodeGen and library support are on hold until the relevant ABI decisions are made.
  2. The supporting AST stuff (serialisation etc.) isn't included yet; this patch is large enough as it is.
  3. 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:

  1. 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.
  2. 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:

  • D50021: [Support] Add casting iterator adapters
  • D50763: [Parser] Refactor and fix bugs in late-parsing
  • D50764: [AST] Make NullStmt final and give it factory functions

Diff Detail

Event Timeline

hamzasood created this revision.Aug 15 2018, 4:59 AM
steveire added inline comments.

Any reason to create the intermediate variable here, instead of leaving the ConsumeToken() call where it was?