[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 09:26:34 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);
----------------
zygoloid wrote:

Thanks for helping me understand :-) I misunderstood your previous comment (any tentative parsing done here will happen anyways when parsing the second operand of the > operator) as suggesting we'd sometimes parse and type-check the same thing twice in a non-ill-formed program. It sounds like we're not doing that, which satisfies my concern here.

https://github.com/llvm/llvm-project/pull/100425


More information about the cfe-commits mailing list