From 35eda446cdf5b4e95a80ffacbf6c7f7478c6d927 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 29 Aug 2009 20:47:47 +0000 Subject: [PATCH] Add a workaround for decls that come from friend decls pointing to undeclared classes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80438 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclBase.cpp | 14 ++++++++++++-- lib/AST/DeclPrinter.cpp | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 3ced0eff4c..3a010b0cdf 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -379,8 +379,18 @@ SourceLocation Decl::getBodyRBrace() const { #ifndef NDEBUG void Decl::CheckAccessDeclContext() const { - assert((Access != AS_none || isa(this) || - !isa(getDeclContext())) && + // If the decl is the toplevel translation unit or if we're not in a + // record decl context, we don't need to check anything. + if (isa(this) || + !isa(getDeclContext())) + return; + + // FIXME: This check should not be necessary - If a friend decl refers to an + // undeclared decl, then that decl shouldn't be in any decl context. + if (getFriendObjectKind() == FOK_Undeclared) + return; + + assert(Access != AS_none && "Access specifier is AS_none inside a record decl"); } diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 191d356755..275f2db82b 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -202,7 +202,10 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { if (PrintAccess) { AccessSpecifier AS = D->getAccess(); - if (AS != CurAS) { + + if (AS != CurAS && + // FIXME: This check shouldn't be necessary. + D->getFriendObjectKind() == Decl::FOK_Undeclared) { Print(AS); Out << ":\n"; CurAS = AS; -- 2.40.0