http://llvm.org/bugs/show_bug.cgi?id=15273
Bug ID: 15273
Summary: Diagnostics for Ambiguous Functions could be improved
Product: clang
Version: 3.2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
This is a motivating example to improve the diagnostics of clang.
The diagnostic messages for ambiguous function templates could be better.
For example, the template parameters are not included in the list of candidates
(produced when compiling the small sample (see end of post) with Xcode):
.../main.cpp:45:5: error: call to 'foo' is ambiguous
nn::A<B,C, void>::foo(i);
^~~~~~~~~~~~~~~~~~~~~
.../main.cpp:26:21: note: candidate function
static void foo(T const& t) {
^
.../main.cpp:28:21: note: candidate function
static void foo(T&& t) {
^
.../main.cpp:26:21: note: candidate function
static void foo(T const& t) {
^
.../main.cpp:28:21: note: candidate function
static void foo(T&& t) {
^
1 error generated.
Expected Results:
The diagnostic messages for ambiguous function templates should be as precise
as necessary in order to identify the reason of the ambiguity. That, for
example, should at least include the template parameters of the ambiguous
functions and should also list any implicit conversions from the argument to
the parameters types.
A verbose diagnostics may include the reason for the equal matched viable
functions. Maybe with same "rank" info?
An extra ordinary cool feature would also include a hint for the most
"unexpected" causes for ambiguity, mainly for non-expert programmers. Since a
user friendly representation of this is possibly very difficult to achieve,
this feature is just a "nice to have".
Sample:
namespace nn {
template <typename...>
struct A;
template <>
struct A<void> {
static void foo() {}
};
template <typename T, typename... Ts>
struct A<T, Ts...> : A<Ts...>
{
using A<Ts...>::foo;
static void foo(T const& t) {
}
static void foo(T&& t) {
}
};
}
int main(int argc, const char * argv[])
{
struct B {
B(int) {}
};
struct C {
C(int) {}
};
const int i = 0;
nn::A<B,C, void>::foo(i);
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs