[patch] Fix pr16247
Rafael EspĂndola
rafael.espindola at gmail.com
Mon Jun 10 16:08:27 PDT 2013
Richard pointed out on IRC that the patch should look at the
redeclaration context to avoid problems with one of the functions
being in a extern "C++". Implementing that found some interesting
problems. Consider
extern "C" {
static void foo(int x);
static void foo() {
}
void foo(int x) {
}
}
This should be valid, since both functions have internal linkage and
therefore none of them has C language linkage. Commenting the first
declaration makes the code invalid as now the last one is extern C and
[dcl.link] p6 kicks in. This means we have to do "normal" overload
resolution first to see if the last decl we are looking at has C
language linkage or not.
Implementing this without doing two passes over the loopkup result is
not trivial. The check of two function overloading has 3 possibilities
* It is a redeclaration
* it is an overload
* it is a redeclaration if the last one has C language linkage.
The attached patch implements it, but I really hope there is a better
way to implement this :-(
Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 9934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130610/b3594015/attachment.obj>
More information about the cfe-commits
mailing list