[cfe-dev] Unreachable at IdentifierResolver.cpp:78 when friend-ing a using declaration

Stephen Lin stephenwlin at gmail.com
Sun Mar 10 14:18:40 PDT 2013


I'm new to clang development but I think I've managed to find
and patch a small issue. I'm not sure what SOP is for this is, so I'm
sending a message here; if this is unnecessary in the future let me

The code below crashes because Sema::CheckOverload assumes that a
function declaration is in the same semantic scope as the current
lexical scope whenever the latter is a record and tries to use member
using hiding rules:

struct A
    void delete_foo();

struct B : public A
    using A::delete_foo;

struct Foo { friend void B::delete_foo(); private: ~Foo() { } };

Similar results are obtained when "friend"-ing a using declaration
declared at namespace scope.

I added a small check to verify that the new function declaration is
actually in the same semantic scope as the current (record) scope: as
far as I can tell this can only affect "friend" declarations. The code
above now triggers an error "declaration conflicts with target of
using declaration already in scope" (I believe this is correct, g++
errors as well) rather than a crash, and added a test for this case.

Bug report at http://llvm.org/bugs/show_bug.cgi?id=15485 with patch attached.

Let me know if there's anything else I can do to help with this issue.


More information about the cfe-dev mailing list