On Mon, Jun 10, 2013 at 4:08 PM, Rafael Espíndola <[email protected]> wrote: > 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 :-(
Here's another alternative: remove the extern "C" checking from IsOverload entirely, and use the LocallyScopedExternCDecls mechanism to enforce the rule instead. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
