Is it legal for a friend to use a declaration?

The following (LiveWorkspace here) is rejected by GCC 4.7.2, GCC 4.8.0 and ICC 13.0.1.

namespace A {
    namespace B {
        void C();
    }
    using B::C;
}

class D {
    friend void A::C();
};

In addition, it breaks Clang 3.2 (!). I already sent an error report and a patch for the error on failure, but I am not 100% sure if this code is really wrong, because I can not find anything in ยง7.3.3 [namespace.udecl] or ยง11.3 [class. friend] , which explicitly resolves this matter, but perhaps there is something in the definition of one of the various terms of the name specifier that I skipped.

Also, it seems that all four compilers accept the following (LiveWorkspace here) :

namespace A {
    namespace B {
        class C;
    }
    using B::C;
}

class D {
    friend class A::C;
};

, , GCC ICC , , . - -, ?

, , , ...

EDIT: clang/trunk!

. Johannes , , , , , GCC ICC (LiveWorkspace ):

namespace A {
    namespace B {
        void C();
    }
    using B::C;

    class D {
        friend void C();
    };
}
+5
1

8.3p1:

, , (, ) (7.3.1)) ; , - declarator.

A class foo; class foo::bar; , . foo::bar (7.1.6.3).

+4

All Articles