]> granicus.if.org Git - clang/commitdiff
Add an ActOnFriendDecl and call it for friend class decls.
authorAnders Carlsson <andersca@mac.com>
Mon, 11 May 2009 22:27:47 +0000 (22:27 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 11 May 2009 22:27:47 +0000 (22:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71482 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
include/clang/Parse/DeclSpec.h
lib/Parse/ParseDeclCXX.cpp

index f70c9f05915ee4ae4c0aeda926490d67df029699..f41e465fe0d6e0428163a36d549a4ea40a0832ba 100644 (file)
@@ -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 --------------------------===//
 
index 9528298109a22dea94b05257b86deedc6b9e6a73..efb7d65c2df585463b44836e3bf705f9d1de66fd 100644 (file)
@@ -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:
index e1e81ec33d3e5eae1eadd36fa5fd33dbb6034182..da99ab9aa2df1498d1ff6bb9af9aaa3956277e65 100644 (file)
@@ -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;
 }