================
@@ -4244,6 +4222,142 @@ void Parser::ParseTrailingRequiresClause(Declarator &D) 
{
   }
 }
 
+std::optional<Parser::ContractSpecifierKind>
+Parser::getContractSpecifierKind() {
+  if (!getLangOpts().CPlusPlus || Tok.isNot(tok::identifier))
+    return std::nullopt;
+
+  if (!Ident_pre) {
+    Ident_pre = &PP.getIdentifierTable().get("pre");
+    Ident_post = &PP.getIdentifierTable().get("post");
+  }
+
+  const IdentifierInfo *II = Tok.getIdentifierInfo();
+  if (II == Ident_pre)
+    return ContractSpecifierKind::Pre;
+  if (II == Ident_post)
+    return ContractSpecifierKind::Post;
+  return std::nullopt;
+}
+
+void Parser::ParseContractSpecifiers(Declarator &D) {
+  assert(getContractSpecifierKind() && "expected a contract specifier");
+
+  if (!getLangOpts().CPlusPlus26)
+    Diag(Tok, diag::err_contracts_require_cxx26);
----------------
erichkeane wrote:

Hmm... I wonder if we should do this as an extension in previous modes?  Any 
reason why that is a bad idea?  (OR at least allow -fcontracts to enable it in 
all C modes).

https://github.com/llvm/llvm-project/pull/221139
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to