[llvm-bugs] [Bug 37191] New: Clang unable to diagnose missing template keyword when unrelated code is added.
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Apr 20 18:58:14 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37191
Bug ID: 37191
Summary: Clang unable to diagnose missing template keyword when
unrelated code is added.
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: rtrieu at google.com
CC: llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180421/a9c5b42d/attachment-0001.html>
More information about the llvm-bugs
mailing list