================
@@ -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()) {
----------------
erichkeane wrote:
Doesn't this disagree with your text above? IF Requires cant follow
'override', why are we letting it be parsed here? Also, are we properly
parsing 'override' between 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