aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-11 22:27:47 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-11 22:27:47 +0000
commit66e9977ddd6b197317d149213b76a9af0d3df4de (patch)
treefe6887677a0b0fe3935e90a1afffb326d794753a
parent5dc2af12bdb8c71c01556f7d5780c5ef94af0306 (diff)
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
-rw-r--r--include/clang/Parse/Action.h7
-rw-r--r--include/clang/Parse/DeclSpec.h1
-rw-r--r--lib/Parse/ParseDeclCXX.cpp14
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<void>()))
+ return;
+ }
+
+ if (DS.isFriendSpecified() &&
+ !Actions.ActOnFriendDecl(CurScope, DS.getFriendSpecLoc(),
+ TagOrTempResult.get()))
+ return;
+
+ if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec,
+ TagOrTempResult.get().getAs<void>()))
Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
}