<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - typo correction leads to bogus "use 'template' keyword" diagnostic"
   href="https://llvm.org/bugs/show_bug.cgi?id=24422">24422</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>typo correction leads to bogus "use 'template' keyword" diagnostic
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org, rikka@google.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase:

struct S { template<typename T> void Allocate(int); };
void f(S Filename) { SM.getAllocator().Allocate<char>(Filename.length() + 1); }

produces this:

<stdin>:1:77: error: use of undeclared identifier 'SM'
struct S { template<typename T> void Allocate(int); }; void f(S Filename) {
SM.getAllocator().Allocate<char>(Filename.length() + 1); }
                                                                            ^
<stdin>:1:95: error: no template named 'Allocate'; did you mean 'S::Allocate'?
struct S { template<typename T> void Allocate(int); }; void f(S Filename) {
SM.getAllocator().Allocate<char>(Filename.length() + 1); }
                                                                               
              ^~~~~~~~
                                                                               
              S::Allocate
<stdin>:1:38: note: 'S::Allocate' declared here
struct S { template<typename T> void Allocate(int); }; void f(S Filename) {
SM.getAllocator().Allocate<char>(Filename.length() + 1); }
                                     ^
<stdin>:1:119: error: no member named 'length' in 'S'
struct S { template<typename T> void Allocate(int); }; void f(S Filename) {
SM.getAllocator().Allocate<char>(Filename.length() + 1); }
                                                                               
                             ~~~~~~~~ ^

The second error here is bogus. We shouldn't have even tried that lookup, since
the LHS expression "SM.getAllocator()" resulted in an error. My original
testcase produced this even worse error:

/usr/local/google/home/richardsmith/build/llvm-9/src/tools/clang/lib/Serialization/ASTReader.cpp:1950:27:
error: use 'template' keyword to treat 'Allocate' as a dependent template name
        SM.getAllocator().Allocate<char>(Filename.length() + 1);
                          ^
                          template 
/usr/local/google/home/richardsmith/build/llvm-9/src/tools/clang/lib/Serialization/ASTReader.cpp:1950:9:
error: use of undeclared identifier 'SM'
        SM.getAllocator().Allocate<char>(Filename.length() + 1);
        ^
/usr/local/google/home/richardsmith/build/llvm-9/src/tools/clang/lib/Serialization/ASTReader.cpp:1950:51:
error: no member named 'length' in 'llvm::StringRef'
        SM.getAllocator().Allocate<char>(Filename.length() + 1);
                                         ~~~~~~~~ ^

... but I'm not sure what other pieces are needed to reproduce that error.
(Here, Filename is a StringRef and SM is undeclared. The enclosing context is
*not* a template, so the "dependent template name" diagnostic is completely
wrong.)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>