This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1821: friend decl. shadows forward decl.



>Number:         1821
>Category:       c++
>Synopsis:       friend decl. shadows forward decl.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 31 08:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Harri Porten
>Release:        gcc version 2.97 20010131 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
gcc bails out on the attached code with:

  test.cpp:8: no type named `B' in `class A'

Moving the forward declaration above the friend declaration
solves the problem. As the two don't refer to each other
I don't see why the order should make a difference, though.

//////////////// test.cpp ////////////////

class A
{
    friend void abc();
    class B;
};

class A::B
{
};
>How-To-Repeat:
gcc -c test.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]