https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118917

            Bug ID: 118917
           Summary: 'class declared private here' points to definition
                    instead
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

class a {
private:
    class b;
};
class a::b {};
void c(a::b&) {}


Expected:

<source>: In function 'void c(a::b&)':
<source>:6:11: error: 'class a::b' is private within this context
    6 | void c(a::b&) {}
      |           ^
<source>:3:11: note: declared private here
    3 |     class b;
      |           ^


Actual:

<source>: In function 'void c(a::b&)':
<source>:6:11: error: 'class a::b' is private within this context
    6 | void c(a::b&) {}
      |           ^
<source>:5:10: note: declared private here
    5 | class a::b {};
      |          ^


That's the definition, not the declaration; it's not where the class is made
private.

If you remove line 5, it correctly points to the declaration on line 3.

Reply via email to