-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[clang] require template arg list after template kw #80801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
2c8c512
bd22435
f6554f9
1e0ecee
8ee685f
ab2d5bd
6ffe7e7
2968561
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
#include "clang/AST/DeclTemplate.h" | ||
#include "clang/AST/ExprCXX.h" | ||
#include "clang/Basic/PrettyStackTrace.h" | ||
#include "clang/Basic/TemplateKinds.h" | ||
#include "clang/Basic/TokenKinds.h" | ||
#include "clang/Lex/LiteralSupport.h" | ||
#include "clang/Parse/ParseDiagnostic.h" | ||
|
@@ -3026,13 +3027,23 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, | |
SS, ObjectType, ObjectHadErrors, | ||
TemplateKWLoc ? *TemplateKWLoc : SourceLocation(), Id, IdLoc, | ||
EnteringContext, Result, TemplateSpecified); | ||
else if (TemplateSpecified && | ||
Actions.ActOnTemplateName( | ||
getCurScope(), SS, *TemplateKWLoc, Result, ObjectType, | ||
EnteringContext, Template, | ||
/*AllowInjectedClassName*/ true) == TNK_Non_template) | ||
return true; | ||
|
||
if (TemplateSpecified) { | ||
TemplateNameKind TNK = | ||
Actions.ActOnTemplateName(getCurScope(), SS, *TemplateKWLoc, Result, | ||
ObjectType, EnteringContext, Template, | ||
/*AllowInjectedClassName=*/true); | ||
if (TNK == TNK_Non_template) | ||
return true; | ||
|
||
// C++ [template.names]p6 | ||
evelez7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// A name prefixed by the keyword template shall be followed by a template | ||
// argument list or refer to a class template or an alias template. | ||
if ((TNK == TNK_Function_template || TNK == TNK_Dependent_template_name || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about type templates: https://godbolt.org/z/1coGTT38P (hmm we may have a wider issue there, from looking at Clang's current behavior, so a FIXME would be reasonable too). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this case isn't covered here. The error fires before reaching this method. I can try to diagnose it for this patch if needed, or I can do a followup patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's reasonable to handle in a follow-up, thanks! |
||
TNK == TNK_Var_template) && | ||
!Tok.is(tok::less)) | ||
Diag(IdLoc, diag::missing_template_arg_list_after_template_kw); | ||
} | ||
return false; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.