================
@@ -78,7 +79,23 @@ bool Parser::isCXXDeclarationStatement(
[[fallthrough]];
// simple-declaration
default:
- return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false);
+
+ if (DisambiguatingWithExpression) {
+ TentativeParsingAction TPA(*this, true);
+ // We will do not check access checks here, because we want to allow
+ // parsing of declarations. Access will be checked later.
+ SuppressAccessChecks AccessExporter(*this, true);
+ if (isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false)) {
+ // Do not annotate the tokens, otherwise access will be neglected
later.
+ TPA.Revert();
+ return true;
+ }
+ TPA.Commit();
+ return false;
+
+ } else {
+ return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false);
+ }
----------------
vgvassilev wrote:
```suggestion
if (DisambiguatingWithExpression) {
TentativeParsingAction TPA(*this, true);
// We will do not check access checks here, because we want to allow
// parsing of declarations. Access will be checked later.
SuppressAccessChecks AccessExporter(*this, true);
if (isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false)) {
// Do not annotate the tokens, otherwise access will be neglected later.
TPA.Revert();
return true;
}
TPA.Commit();
return false;
}
return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false);
}
```
We don't need an else-after-return
https://github.com/llvm/llvm-project/pull/178842
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits