Skip to content

Commit 692b0ae

Browse files
committed
issue #10506 Keyword-like forms of logical operators are not supported in C++ requires clause
1 parent 6dd6830 commit 692b0ae

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

src/scanner.l

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ BNopt {BN}*
261261
BL [ \t\r]*"\n"
262262
B [ \t]
263263
Bopt {B}*
264+
NOTopt (("!"{BNopt})|("not"{BN}+))?
264265
DIGIT [0-9]
265266
HEXDIGIT ({DIGIT}|[a-f]|[A-F])
266267
ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
@@ -2298,20 +2299,10 @@ NONLopt [^\n]*
22982299
yyextra->roundCount=0;
22992300
BEGIN( CopyRound ) ;
23002301
}
2301-
<RequiresClause>{ID} { // something like "requires true"
2302-
if (startOfRequiresExpression(yyextra->current->req))
2303-
{
2304-
yyextra->current->req=yytext;
2305-
BEGIN(yyextra->requiresContext);
2306-
}
2307-
else
2308-
{
2309-
REJECT;
2310-
}
2311-
}
2312-
<RequiresClause>{SCOPENAME}{BNopt}"(" { // "requires func(x)"
2302+
<RequiresClause>{NOTopt}{SCOPENAME}{BNopt}"(" { // "requires func(x)"
23132303
if (startOfRequiresExpression(yyextra->current->req))
23142304
{
2305+
lineCount(yyscanner);
23152306
yyextra->current->req+=yytext;
23162307
yyextra->lastRoundContext=RequiresClause;
23172308
yyextra->pCopyRoundString=&yyextra->current->req;
@@ -2323,9 +2314,10 @@ NONLopt [^\n]*
23232314
REJECT;
23242315
}
23252316
}
2326-
<RequiresClause>{SCOPENAME}{BNopt}"<" { // "requires C<S,T>"
2317+
<RequiresClause>{NOTopt}{SCOPENAME}{BNopt}"<" { // "requires C<S,T>"
23272318
if (startOfRequiresExpression(yyextra->current->req))
23282319
{
2320+
lineCount(yyscanner);
23292321
yyextra->current->req+=yytext;
23302322
yyextra->lastSharpContext=RequiresClause;
23312323
yyextra->pCopySharpString=&yyextra->current->req;
@@ -2337,10 +2329,24 @@ NONLopt [^\n]*
23372329
REJECT
23382330
}
23392331
}
2340-
<RequiresClause>"::"{ID} {
2332+
<RequiresClause>{NOTopt}{SCOPENAME} { // something like "requires true" or "requires !my::value"
2333+
if (startOfRequiresExpression(yyextra->current->req))
2334+
{
2335+
lineCount(yyscanner);
2336+
yyextra->current->req=yytext;
2337+
BEGIN(yyextra->requiresContext);
2338+
}
2339+
else
2340+
{
2341+
REJECT;
2342+
}
2343+
}
2344+
<RequiresClause>{NOTopt}"::"{ID} {
2345+
lineCount(yyscanner);
23412346
yyextra->current->req+=yytext;
23422347
}
2343-
<RequiresClause>"||"|"&&" { // "requires A || B" or "requires A && B"
2348+
<RequiresClause>"||"|"&&"|"!"|("or"{BN}+)|("and"{BN}+)|("not"{BN}+) { // "requires A || B" or "requires A && B"
2349+
lineCount(yyscanner);
23442350
yyextra->current->req+=yytext;
23452351
}
23462352
<RequiresClause>{BN}+ {
@@ -7506,7 +7512,7 @@ static QCString stripFuncPtr(const QCString &type)
75067512
static bool startOfRequiresExpression(const QCString &req)
75077513
{
75087514
QCString r = req.stripWhiteSpace();
7509-
return r.isEmpty() || r.endsWith("&&") || r.endsWith("||");
7515+
return r.isEmpty() || r.endsWith("&&") || r.endsWith("||") || r.endsWith("and") || r.endsWith("or");
75107516
}
75117517
75127518
//-----------------------------------------------------------------

0 commit comments

Comments
 (0)