]> granicus.if.org Git - clang/commitdiff
Stop diagnosing the use of inner classes as friends. ddunbar asked whether
authorJohn McCall <rjmccall@apple.com>
Tue, 22 Dec 2009 00:59:39 +0000 (00:59 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 22 Dec 2009 00:59:39 +0000 (00:59 +0000)
this was useful, and on review Doug and I decided it was probably on the level
of a bug in the standard and therefore not worth a warning even in -pedantic.
If someone disagrees and urgently wants clang++ to warn about this in strict
c++98 mode, we can talk about it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91868 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclCXX.cpp

index 3662bd4793da5ad8e24a49bb9893ffd36b4a09c1..eece90b42a6fcc87183d82fc50e579ae65f48216 100644 (file)
@@ -351,8 +351,6 @@ def err_enum_friend : Error<
   "enum types cannot be friends">;
 def err_friend_is_member : Error<
   "friends cannot be members of the declaring class">;
-def ext_friend_inner_class : Extension<
-  "C++ 98 does not allow inner classes as friends">;
 def err_unelaborated_friend_type : Error<
   "must specify '%select{struct|union|class|enum}0' to befriend %1">;
 def err_qualified_friend_not_found : Error<
index 1f3fbba629efbcebdca148e5db85f4752a0885f6..13b65e3000b3ae8240932ea546b7702c44c7202f 100644 (file)
@@ -5196,13 +5196,10 @@ Sema::DeclPtrTy Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
 
   // C++98 [class.friend]p1: A friend of a class is a function
   //   or class that is not a member of the class . . .
-  // But that's a silly restriction which nobody implements for
-  // inner classes, and C++0x removes it anyway, so we only report
-  // this (as a warning) if we're being pedantic.
-  if (!getLangOptions().CPlusPlus0x)
-    if (const RecordType *RT = T->getAs<RecordType>())
-      if (RT->getDecl()->getDeclContext() == CurContext)
-        Diag(DS.getFriendSpecLoc(), diag::ext_friend_inner_class);
+  // This is fixed in DR77, which just barely didn't make the C++03
+  // deadline.  It's also a very silly restriction that seriously
+  // affects inner classes and which nobody else seems to implement;
+  // thus we never diagnose it, not even in -pedantic.
 
   Decl *D;
   if (TempParams.size())