<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Unhelpful diagnostics when template parameters accidentally repeated after name"
   href="https://bugs.llvm.org/show_bug.cgi?id=39670">39670</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unhelpful diagnostics when template parameters accidentally repeated after name
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>comexk@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Here is some erroneous code where the list of template parameters is
accidentally repeated after the name of the item being declared:

--

// declaration #1
template <typename T>
void foo<T>() {}

struct X {
    // declaration #2
    template <typename T>
    void foo<T>() {}
    // declaration #3
    template <typename T>
    using Bar<T> = int;
};

--

(I sometimes make this error because writing the template parameters after the
name is necessary in C++ for partial specializations, and always done in some
other languages.)


However, the error messages are not as helpful as they could be:

--

/tmp/foo.cpp:2:6: error: variable has incomplete type 'void'
void foo<T>() {}
     ^
/tmp/foo.cpp:2:9: error: expected ';' at end of declaration
void foo<T>() {}
        ^
        ;
/tmp/foo.cpp:2:9: error: expected unqualified-id
/tmp/foo.cpp:6:10: error: function template partial specialization is not
allowed
    void foo<T>() {}
         ^  ~~~
/tmp/foo.cpp:8:5: error: cannot template a using declaration
    using Bar<T> = int;
    ^
/tmp/foo.cpp:8:14: error: expected member name or ';' after declaration
specifiers
    using Bar<T> = int;

--

Declaration #1 gets parsed as a variable declaration for some reason, even
though variable templates are equally ineligible for partial specialization.

Declaration #2 is closest to having a useful diagnostic ("function template
partial specialization is not allowed"), but it would be nice if Clang had a
more specific diagnostic suggesting removing the <T>.

For Declaration #3, the error message "cannot template a using declaration" is
outright inaccurate.  It *is* possible to template a using declaration, just
not to partially specialize one.</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>