[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 30 13:35:23 PDT 2024
================
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult &PotentialTemplateName) {
Priority);
}
+bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) {
+ assert(Tok.is(tok::coloncolon));
+ Sema::DisableTypoCorrectionRAII DTC(Actions);
+ ColonProtectionRAIIObject ColonProtection(*this);
+
+ SourceLocation StartLoc = Tok.getLocation();
+ if (TryAnnotateTypeOrScopeToken())
+ return true;
+ if (Tok.isSimpleTypeSpecifier(getLangOpts()))
+ return false;
+ CXXScopeSpec SS;
+ ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+ /*ObjectHasErrors=*/false,
+ /*EnteringContext=*/false);
+ ExprResult Result = tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false);
----------------
sdkrystian wrote:
For a well-formed program, any tentative parsing done here will happen anyways when parsing the second operand of the `>` operator. Only for an _ill-formed_ program (i.e. one where `template` is missing) do we instantiate things that should not be instantiated.
As an alternative, we could also just lookup the name immediately following the `::` _nested-name-specifier_ and make the determination based on that.
https://github.com/llvm/llvm-project/pull/100425
More information about the cfe-commits
mailing list