[PATCH] D48571: improve diagnostics for missing 'template' keyword

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 25 14:58:49 PDT 2018


rsmith created this revision.
rsmith added a reviewer: dblaikie.
Herald added a subscriber: eraman.

We track when we see a name-shaped expression followed by a `<` token that we parse as a comparison. Then:

- if we see a token sequence that cannot possibly be an expression but can be a template argument (in particular, a //type-id//) that follows either a `,` or the `<`, diagnose that the `<` was supposed to start a template argument list
- if we see `<>`, diagnose that the `<>` was supposed to be a template argument list
- if we see `>()`, diagnose that the `<`[...]`>` was supposed to be a template argument list

This only changes the diagnostic for error cases, and in practice appears to catch the most common cases where a missing `template` keyword leads to parse errors within a template.


Repository:
  rC Clang

https://reviews.llvm.org/D48571

Files:
  include/clang/Basic/BitmaskEnum.h
  include/clang/Parse/Parser.h
  include/clang/Parse/RAIIObjectsForParser.h
  include/clang/Sema/Sema.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaTemplate/dependent-template-recover.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48571.152780.patch
Type: text/x-patch
Size: 21894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180625/cd718906/attachment-0001.bin>


More information about the cfe-commits mailing list