summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-27 05:57:59 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-27 05:57:59 +0000
commit2f88d7d72c006d78810212dce53101331efab44a (patch)
tree877c6261227e90ce5ada76ed29cb955893ccdd44 /clang/lib/Sema/SemaDecl.cpp
parentb832e3276ab60cdaf913250f5c97d76f8a362719 (diff)
downloadbcm5719-llvm-2f88d7d72c006d78810212dce53101331efab44a.tar.gz
bcm5719-llvm-2f88d7d72c006d78810212dce53101331efab44a.zip
Implement method friends in class templates and fix a few related problems.
llvm-svn: 99708
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9bdcf09b296..9dbe821ee8e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2998,13 +2998,13 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
"previously-undeclared friend function being created "
"in a non-namespace context");
+ // For now, claim that the objects have no previous declaration.
if (FunctionTemplate) {
- FunctionTemplate->setObjectOfFriendDecl(
- /* PreviouslyDeclared= */ !Previous.empty());
+ FunctionTemplate->setObjectOfFriendDecl(false);
FunctionTemplate->setAccess(AS_public);
+ } else {
+ NewFD->setObjectOfFriendDecl(false);
}
- else
- NewFD->setObjectOfFriendDecl(/* PreviouslyDeclared= */ !Previous.empty());
NewFD->setAccess(AS_public);
}
@@ -3154,6 +3154,17 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Previous.getResultKind() != LookupResult::FoundOverloaded) &&
"previous declaration set still overloaded");
+ if (isFriend && Redeclaration) {
+ AccessSpecifier Access = NewFD->getPreviousDeclaration()->getAccess();
+ if (FunctionTemplate) {
+ FunctionTemplate->setObjectOfFriendDecl(true);
+ FunctionTemplate->setAccess(Access);
+ } else {
+ NewFD->setObjectOfFriendDecl(true);
+ }
+ NewFD->setAccess(Access);
+ }
+
// If we have a function template, check the template parameter
// list. This will check and merge default template arguments.
if (FunctionTemplate) {
OpenPOWER on IntegriCloud