@@ -1802,6 +1802,38 @@ bool Parser::checkPotentialAngleBracketDelimiter(
18021802 return true ;
18031803 }
18041804
1805+ if (OpToken.is (tok::greater) && Tok.is (tok::coloncolon)) {
1806+ SourceLocation StartLoc = Tok.getLocation ();
1807+ CXXScopeSpec SS;
1808+ ParseOptionalCXXScopeSpecifier (SS, /* ObjectType=*/ nullptr ,
1809+ /* ObjectHasErrors=*/ false ,
1810+ /* EnteringContext=*/ false );
1811+ ExprResult Result =
1812+ tryParseCXXIdExpression (SS, /* isAddressOfOperand=*/ false );
1813+ bool Invalid = !Result.isUsable () || Result.get ()->containsErrors ();
1814+ Result = Actions.CorrectDelayedTyposInExpr (Result);
1815+
1816+ if (PP.isBacktrackEnabled ())
1817+ PP.RevertCachedTokens (1 );
1818+ else
1819+ PP.EnterToken (Tok, /* IsReinject=*/ true );
1820+
1821+ SourceLocation EndLoc = Tok.getLocation ();
1822+ Tok.setLocation (StartLoc);
1823+ Tok.setKind (tok::annot_primary_expr);
1824+ setExprAnnotation (Tok, Result);
1825+ Tok.setAnnotationEndLoc (EndLoc);
1826+ PP.AnnotateCachedTokens (Tok);
1827+
1828+ if (Invalid) {
1829+ Actions.diagnoseExprIntendedAsTemplateName (
1830+ getCurScope (), LAngle.TemplateName , LAngle.LessLoc ,
1831+ OpToken.getLocation ());
1832+ AngleBrackets.clear (*this );
1833+ return true ;
1834+ }
1835+ }
1836+
18051837 // After a '>' (etc), we're no longer potentially in a construct that's
18061838 // intended to be treated as a template-id.
18071839 if (OpToken.is (tok::greater) ||
0 commit comments