================
@@ -2591,21 +2592,30 @@ bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
BitfieldSize = ParseConstantExpression();
if (BitfieldSize.isInvalid())
SkipUntil(tok::comma, StopAtSemi | StopBeforeMatch);
- } else if (Tok.is(tok::kw_requires)) {
- TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
- // With abbreviated function templates - we need to explicitly add depth to
- // account for the implicit template parameter list induced by the
template.
- if (DeclaratorInfo.getTemplateParameterLists().empty() &&
- DeclaratorInfo.getInventedTemplateParameterList())
- ++CurTemplateDepthTracker;
- ParseTrailingRequiresClauseWithScope(DeclaratorInfo);
} else {
- ParseOptionalCXX11VirtSpecifierSeq(
- VS, getCurrentClass().IsInterface,
- DeclaratorInfo.getDeclSpec().getFriendSpecLoc());
- if (!VS.isUnset())
- MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
- VS);
+ // Requires clause can't follow 'override' but contracts can follow
+ // 'override'. Even if we don't support virtual functions with contractcs,
+ // we should diagnose at the sema stage instead of the parser stage.
+ if (Tok.isNot(tok::kw_requires)) {
+ ParseOptionalCXX11VirtSpecifierSeq(
+ VS, getCurrentClass().IsInterface,
+ DeclaratorInfo.getDeclSpec().getFriendSpecLoc());
+ if (!VS.isUnset())
+ MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
+ VS);
+ }
+
+ if (Tok.is(tok::kw_requires) || getContractSpecifierKind()) {
+ TemplateParameterDepthRAII CurTemplateDepthTracker(
+ TemplateParameterDepth);
+ // With abbreviated function templates - we need to explicitly add depth
+ // to account for the implicit template parameter list induced by the
+ // template.
+ if (DeclaratorInfo.getTemplateParameterLists().empty() &&
+ DeclaratorInfo.getInventedTemplateParameterList())
+ ++CurTemplateDepthTracker;
+ ParseFunctionContractSpecifiersAndConstraints(DeclaratorInfo);
----------------
erichkeane wrote:
I am perhaps not great at reading this, but I can't help but wonder if
combining contract specifiers and constraints is mis-guided? There is a lot of
the 'in the middle' stuff that I'm not sure we're doing right?
https://github.com/llvm/llvm-project/pull/221139
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits