<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 - Clang unable to diagnose missing template keyword when unrelated code is added."
href="https://bugs.llvm.org/show_bug.cgi?id=37191">37191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang unable to diagnose missing template keyword when unrelated code is added.
</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>Linux
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rtrieu@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Clang is able to diagnose a missing template keyword for good-diagnostic.cc
below. However, if some unrelated code is added as in bad-diagnostic.cc below,
an incorrect diagnostic about overloaded functions is emitted instead.
$ cat good-diagnostic.cc
template <typename T, int N>
struct Foo {
template <int Shift>
static void bar(T arr[N]) {}
};
template <typename T, int Width, int Stride>
void test() {
T in[Width];
Foo<T, Width>::bar<Stride>(in);
}
void run() {
test<int, 10, 10>();
}
$ clang good-diagnostic.cc
good-diagnostic.cc:10:3: error: missing 'template' keyword prior to dependent
template name 'bar'
Foo<T, Width>::bar<Stride>(in);
^
good-diagnostic.cc:14:3: note: in instantiation of function template
specialization 'test<int, 10, 10>' requested here
test<int, 10, 10>();
^
1 error generated.
$ cat bad-diagnostic.cc
struct S {};
bool run(const S a, const S b);
bool operator< (const S &s1, const S &s2) { return run(s1, s2); }
bool operator>=(const S &s1, const S &s2) { return run(s1, s2); }
bool operator<=(const S &s1, const S &s2) { return run(s1, s2); }
template <typename T, int N>
struct Foo {
template <int Shift>
static void bar(T arr[N]) {}
};
template <typename T, int Width, int Stride>
void test() {
T in[Width];
Foo<T, Width>::bar<Stride>(in);
}
void run() {
test<int, 10, 10>();
}
$ clang bad-diagnostic.cc
bad-diagnostic.cc:18:3: error: reference to overloaded function could not be
resolved; did you mean to call it?
Foo<T, Width>::bar<Stride>(in);
^~~~~~~~~~~~~~~~~~
bad-diagnostic.cc:22:3: note: in instantiation of function template
specialization 'test<int, 10, 10>' requested here
test<int, 10, 10>();
^
bad-diagnostic.cc:12:15: note: possible target for call
static void bar(T arr[N]) {}
^
1 error generated.</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>