From: John McCall Date: Tue, 22 Dec 2009 00:59:39 +0000 (+0000) Subject: Stop diagnosing the use of inner classes as friends. ddunbar asked whether X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a236a5584732c7c285316d7608168f771fac2059;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91868 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 3662bd4793..eece90b42a 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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< diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 1f3fbba629..13b65e3000 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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()) - 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())