Andrew Sutton <andrew.n.sut...@gmail.com> writes: | Attached is the stubbed out parsing for requires expressions. I plan | on implementing semantics next.
See comments below. | I haven't pushed this into a git branch since its a completely | separate change from the previous patch. Should I create a new branch | for separate work? Unless it is fundamentally different, I would prefer that we have just one branch to deal with. | + // Concept extensions | + case RID_REQUIRES: | + return cp_parser_requires_expression (parser); | + I think you meant here "nested requirements", not "extensions" as in "GNU extensions" or "vendor lock-ins". We should continue with "nested requirements" then. | /* Objective-C++ expressions. */ | case RID_AT_ENCODE: | case RID_AT_PROTOCOL: | @@ -21417,6 +21449,25 @@ cp_parser_label_declaration (cp_parser* | cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON); | } | +// -------------------------------------------------------------------------- // | +// Requires Clause | + | +// Parse a requires clause. | +// | +// requires-clause: | +// 'requires' constant-expression | +// | +static inline tree | +cp_parser_requires_clause (cp_parser *parser) | +{ | + // Parse the constant expression. | + tree expr = | + cp_parser_binary_expression (parser, false, false, PREC_NOT_OPERATOR, NULL); | + if (!require_potential_rvalue_constant_expression (expr)) | + return error_mark_node; | + return expr; The grammar says "constant-expression". You should use cp_parser_constant_expression. [...] Patch OK, with the comments above. -- Gaby