[cfe-commits] r142393 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/class/class.friend/p1-cxx11.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Tue Oct 18 11:33:57 PDT 2011
Author: rsmith
Date: Tue Oct 18 13:33:57 2011
New Revision: 142393
URL: http://llvm.org/viewvc/llvm-project?rev=142393&view=rev
Log:
In C++11, a class's members are allowed to be nominated as friends.
Added:
cfe/trunk/test/CXX/class/class.friend/p1-cxx11.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=142393&r1=142392&r2=142393&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Oct 18 13:33:57 2011
@@ -10045,7 +10045,7 @@
// C++ [class.friend]p1: A friend of a class is a function or
// class that is not a member of the class . . .
- if (DC->Equals(CurContext))
+ if (DC->Equals(CurContext) && !getLangOptions().CPlusPlus0x)
Diag(DS.getFriendSpecLoc(), diag::err_friend_is_member);
if (D.isFunctionDefinition()) {
Added: cfe/trunk/test/CXX/class/class.friend/p1-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.friend/p1-cxx11.cpp?rev=142393&view=auto
==============================================================================
--- cfe/trunk/test/CXX/class/class.friend/p1-cxx11.cpp (added)
+++ cfe/trunk/test/CXX/class/class.friend/p1-cxx11.cpp Tue Oct 18 13:33:57 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+class A {
+ class AInner {
+ };
+
+ void a_member();
+ friend void A::a_member(); // ok in c++11, ill-formed in c++98
+ friend void a_member(); // ok in both, refers to non-member
+ friend class A::AInner; // ok in c++11, extension in c++98
+ friend class AInner; // ok in both, refers to non-member
+};
More information about the cfe-commits
mailing list