From 66e9977ddd6b197317d149213b76a9af0d3df4de Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Mon, 11 May 2009 22:27:47 +0000 Subject: [PATCH] Add an ActOnFriendDecl and call it for friend class decls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71482 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Parse/Action.h | 7 +++++++ include/clang/Parse/DeclSpec.h | 1 + lib/Parse/ParseDeclCXX.cpp | 14 +++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index f70c9f0591..f41e465fe0 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -933,6 +933,13 @@ public: return DeclPtrTy(); } + /// ActOnFriendDecl - This action is called when a friend declaration is + /// encountered. Returns false on success. + virtual bool ActOnFriendDecl(Scope *S, SourceLocation FriendLoc, + DeclPtrTy Dcl) { + return false; + } + //===------------------------- C++ Expressions --------------------------===// diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h index 9528298109..efb7d65c2d 100644 --- a/include/clang/Parse/DeclSpec.h +++ b/include/clang/Parse/DeclSpec.h @@ -284,6 +284,7 @@ public: bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec); bool isFriendSpecified() const { return Friend_specified; } + SourceLocation getFriendSpecLoc() const { return FriendLoc; } /// AddAttributes - contatenates two attribute lists. /// The GCC attribute syntax allows for the following: diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index e1e81ec33d..da99ab9aa2 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -525,10 +525,18 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, } const char *PrevSpec = 0; - if (TagOrTempResult.isInvalid()) + if (TagOrTempResult.isInvalid()) { DS.SetTypeSpecError(); - else if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, - TagOrTempResult.get().getAs())) + return; + } + + if (DS.isFriendSpecified() && + !Actions.ActOnFriendDecl(CurScope, DS.getFriendSpecLoc(), + TagOrTempResult.get())) + return; + + if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, + TagOrTempResult.get().getAs())) Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec; } -- 2.40.0