From af0cc7fd27117ec48c503d3e68bc10f3c5f8fce9 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 16 Mar 2012 19:51:19 +0000 Subject: [PATCH] Skip through transparent contexts when deciding where to add a friend function. This fixes g++.dg/parse/friend5.C. llvm-svn: 152938 --- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- clang/test/SemaCXX/friend.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 79a5d4c98c57..c8c3af3cd541 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -10060,7 +10060,7 @@ Decl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, // declarations should stop at the nearest enclosing namespace, // not that they should only consider the nearest enclosing // namespace. - while (DC->isRecord()) + while (DC->isRecord() || DC->isTransparentContext()) DC = DC->getParent(); LookupQualifiedName(Previous, DC); diff --git a/clang/test/SemaCXX/friend.cpp b/clang/test/SemaCXX/friend.cpp index b1ef220e534c..c5b11eb5a338 100644 --- a/clang/test/SemaCXX/friend.cpp +++ b/clang/test/SemaCXX/friend.cpp @@ -130,3 +130,11 @@ namespace test6_3 { v.f(); } } + +namespace test7 { + extern "C" { + class X { + friend int f() { return 42; } + }; + } +}