================
@@ -2462,6 +2467,35 @@ StmtResult Parser::ParseBreakStatement() {
return ParseBreakOrContinueStatement(/*IsContinue=*/false);
}
+StmtResult Parser::ParseContractAssertStatement() {
+ assert(Tok.is(tok::kw_contract_assert) && "expected contract_assert");
+ if (!getLangOpts().Contracts)
+ Diag(Tok, diag::err_contracts_disabled);
+ SourceLocation ContractAssertLoc = ConsumeToken();
+
+ ParsedAttributes Attrs(AttrFactory);
+ MaybeParseCXX11Attributes(Attrs);
+
+ BalancedDelimiterTracker T(*this, tok::l_paren);
+ if (T.expectAndConsume(diag::err_expected_lparen_after, "contract_assert")) {
+ SkipUntil(tok::semi, StopBeforeMatch);
+ return Actions.ActOnNullStmt(ContractAssertLoc,
+ /*HasLeadingEmptyMacro=*/false);
+ }
+
+ EnterExpressionEvaluationContext Evaluated(
+ Actions, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+ ExprResult Predicate = ParseConditionalExpression();
+ if (Predicate.isInvalid())
+ T.skipToEnd();
+ else
+ T.consumeClose();
+
+ // TODO: Now we don't build AST node for contracts.
+ return Actions.ActOnNullStmt(ContractAssertLoc,
----------------
ChuanqiXu9 wrote:
BTW, if we reject them all, the point of test in this PR may be worse as all
cases are rejected.
And also, we can even see the current situation as mimic to the ignoring mode.
And in summary, I think this is a WIP feature and we don't need to worry too
much about users misuse it during the develop process while we even didn't
offer official interface for them.
https://github.com/llvm/llvm-project/pull/221139
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits