[cfe-commits] r91868 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclCXX.cpp

John McCall rjmccall at apple.com
Mon Dec 21 16:59:39 PST 2009


Author: rjmccall
Date: Mon Dec 21 18:59:39 2009
New Revision: 91868

URL: http://llvm.org/viewvc/llvm-project?rev=91868&view=rev
Log:
Stop diagnosing the use of inner classes as friends.  ddunbar asked whether
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.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=91868&r1=91867&r2=91868&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec 21 18:59:39 2009
@@ -351,8 +351,6 @@
   "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<

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=91868&r1=91867&r2=91868&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec 21 18:59:39 2009
@@ -5196,13 +5196,10 @@
 
   // 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())





More information about the cfe-commits mailing list