public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* diagnostic feature request
@ 2011-08-26 11:54 Nathan Ridge
  2011-11-23  3:31 ` Nathan Ridge
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Ridge @ 2011-08-26 11:54 UTC (permalink / raw)
  To: GCC Help Mailing List


Hi,

I have a feature request regarding a compiler diagnostic.

When a call of an overloaded function is ambiguous, and some of the candidates
are declared in namespaces other than the namespace of the call site (or one
of its parent namespaces), it would be helpful if the compiler helped us 
figure out why those candidates are visible in the namespace of the call site.

Specifically, it would be helpful if the compiler would say:

 - whether the candidate is visible 1) because it was imported into the 
   namespace of the call site (or one of its parent namespaces) via a
   using-declaration or a using-directive, OR 2) because it was found
   using argument-dependent lookup

 - in the first case, the location of the using-declaration or using-
   directive (if there are several, any one of them should suffice)

 - in the second case, the argument that triggered the argument-
   dependent lookup and why

Examples:

///////////////  EXAMPLE 1  ///////////////

namespace n1
{
    void foo(double);
}

using n1::foo;

void foo(float);

int main()
{
   foo(0);   
}

// Current diagnostic
test.cpp: In function 'int main()':
test.cpp:12:9: error: call of overloaded 'foo(int)' is ambiguous
test.cpp:12:9: note: candidates are:
test.cpp:3:10: note: void n1::foo(double)
test.cpp:8:6: note: void foo(float)

// What I would like to see
test.cpp: In function 'int main()':
test.cpp:12:9: error: call of overloaded 'foo(int)' is ambiguous
test.cpp:12:9: note: candidates are:
test.cpp:3:10: note: void n1::foo(double)
test.cpp:6:13: note: visible in global namespace because of using-declaration located here
test.cpp:8:6: note: void foo(float)


///////////////  EXAMPLE 2  ///////////////

namespace n1
{
    struct Bar {};

    void foo(double, Bar);
}

void foo(float, n1::Bar);

int main()
{
   foo(n1::Bar());   
}

// Current diagnostic
test.cpp: In function 'int main()':
test.cpp:12:20: error: call of overloaded 'foo(int, n1::Bar)' is ambiguous
test.cpp:12:20: note: candidates are:
test.cpp:8:6: note: void foo(float, n1::Bar)
test.cpp:5:10: note: void n1::foo(double, n1::Bar)

// What I would like to see
test.cpp: In function 'int main()':
test.cpp:12:20: error: call of overloaded 'foo(int, n1::Bar)' is ambiguous
test.cpp:12:20: note: candidates are:
test.cpp:8:6: note: void foo(float, n1::Bar)
test.cpp:5:10: note: void n1::foo(double, n1::Bar)
test.cpp:3:14: note: found by argument-dependent lookup because second argument is of type n1::Bar

//////////////////////////////////////////


Does this sound doable? Should I open a ticket for this feature request?

Thanks,
Nate 		 	   		  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: diagnostic feature request
  2011-08-26 11:54 diagnostic feature request Nathan Ridge
@ 2011-11-23  3:31 ` Nathan Ridge
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Ridge @ 2011-11-23  3:31 UTC (permalink / raw)
  To: GCC Help Mailing List


> I have a feature request regarding a compiler diagnostic.
> 
> [snip]

I submitted a ticket for this: 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51277

Thanks,
Nate
 		 	   		  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-23  0:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 11:54 diagnostic feature request Nathan Ridge
2011-11-23  3:31 ` Nathan Ridge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).