[cfe-dev] Patch to correct compilation errors related to class friend declarations
Tom Honermann
thonermann at coverity.com
Fri Nov 4 20:34:41 PDT 2011
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. Since, as far as I know, there is no way to
forward declare a nested class without first defining the parent class,
nor to grant friendship to a nested class of an undefined class, I
"fixed" this by proxying the enum constants through the befriended
class. It might make more sense to simply make these few enum types public.
llvm-trunk/tools/clang/include/clang/Parse/Parser.h: In destructor
'clang::Parser::BalancedDelimiterTracker::~BalancedDelimiterTracker()':
llvm-trunk/tools/clang/include/clang/Parse/Parser.h:439: error: 'void
clang::Parser::DelimiterTracker::pop(clang::tok::TokenKind)' is private
llvm-trunk/tools/clang/include/clang/Parse/Parser.h:479: error: within
this context
This error also looks legit to me. A nested class is attempting to
access a private method of a peer nested class without being declared a
friend. This appears to me to violate C++03 11.8.1 [class.access.nest].
The patch adds a friendship declaration and a forward declaration for
the befriended class.
Tom.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: clang-friend-fixes.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111104/8607c223/attachment.ksh>
More information about the cfe-dev
mailing list