]> granicus.if.org Git - clang/commit
When we see a '<' operator, check whether it's a probable typo for a template-id.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 10 May 2017 02:30:28 +0000 (02:30 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 10 May 2017 02:30:28 +0000 (02:30 +0000)
commit327d010bc81cbf3656ac46faa24109c7c0f1f624
treeb6292a2f16a0af6092b43e70dc3506e81fd07c12
parent23f58ce5d2805d7f2fb9818f04cb7541319a5307
When we see a '<' operator, check whether it's a probable typo for a template-id.

The heuristic that we use here is:
 * the left-hand side must be a simple identifier or a class member access
 * the right-hand side must be '<' followed by either a '>' or by a type-id that
   cannot be an expression (in particular, not followed by '(' or '{')
 * there is a '>' token matching the '<' token

The second condition guarantees the expression would otherwise be ill-formed.

If we're confident that the user intended the name before the '<' to be
interpreted as a template, diagnose the fact that we didn't interpret it
that way, rather than diagnosing that the template arguments are not valid
expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302615 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Parse/Parser.h
include/clang/Sema/Sema.h
lib/Parse/ParseExpr.cpp
lib/Sema/SemaTemplate.cpp
test/SemaCXX/cxx1y-variable-templates_top_level.cpp
test/SemaTemplate/typo-template-name.cpp [new file with mode: 0644]