[cfe-dev] Patch to correct compilation errors related to class friend declarations

John McCall rjmccall at apple.com
Sat Nov 5 00:05:03 PDT 2011


On Nov 4, 2011, at 8:34 PM, Tom Honermann wrote:
> I checked out cfe/trunk today and attempted a build using an older gcc compiler (4.0.3) on Linux.  The build failed in a few places with the errors below.  The attached patch corrects these.  Each of the errors was related to class friend declarations.
> 
> llvm-trunk/tools/clang/include/clang/Basic/Diagnostic.h:590: error: 'clang::DiagnosticsEngine::<anonymous enum> clang::DiagnosticsEngine::MaxArguments' is private
> llvm-trunk/tools/clang/include/clang/Basic/PartialDiagnostic.h:36: error: within this context
> llvm-trunk/tools/clang/include/clang/Basic/Diagnostic.h:621: error: 'clang::DiagnosticsEngine::<anonymous enum> clang::DiagnosticsEngine::MaxFixItHints' is private
> llvm-trunk/tools/clang/include/clang/Basic/PartialDiagnostic.h:68: error: within this context
> 
> This error looks legit to me.  The code appears to be violating C++03 11.4.2 [class.friend] and 11.8.1 [class.access.nest].  Granting friendship to a class does not confer friendship to nested classes of the befriended class.

It does, actually:
  [class.access]p2: A member of a class can also access all the names to which the class has access.
  [class.access.nest]p1: A nested class is a member and as such has the same access rights as any other member.
It's the other way that doesn't hold;  having access to a class doesn't give you access to its nested classes.

John.



More information about the cfe-dev mailing list