[PATCH] MSVC compat: Allow lookup of friend types in enclosing namespaces
Richard Smith
richard at metafoo.co.uk
Wed Jul 9 17:04:57 PDT 2014
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1000-1002
@@ -999,2 +999,5 @@
InGroup<UnsupportedFriend>;
-
+def ext_friend_tag_redecl_outside_namespace : ExtWarn<
+ "unqualified friend declarations referring to types outside of the nearest "
+ "enclosing namespace is a Microsoft extension; add a nested name specifier to fix">,
+ InGroup<Microsoft>;
----------------
Please add a bit more information here: which NNS should be added? What is the enclosing namespace that we looked in? Which type did we actually find? A fixit adding the NNS would help.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1001
@@ +1000,3 @@
+def ext_friend_tag_redecl_outside_namespace : ExtWarn<
+ "unqualified friend declarations referring to types outside of the nearest "
+ "enclosing namespace is a Microsoft extension; add a nested name specifier to fix">,
----------------
Singular/plural mismatch ("declarations ... is a MS extension"). Please make this singular.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1002
@@ +1001,3 @@
+ "unqualified friend declarations referring to types outside of the nearest "
+ "enclosing namespace is a Microsoft extension; add a nested name specifier to fix">,
+ InGroup<Microsoft>;
----------------
Maybe drop the "to fix"?
================
Comment at: lib/Sema/SemaDecl.cpp:11467
@@ -11453,3 +11466,3 @@
if (TUK == TUK_Friend)
New->setObjectOfFriendDecl(!FriendSawTagOutsideEnclosingNamespace &&
getLangOpts().MicrosoftExt);
----------------
This was a prior attempt to get ~half of the same effect. In particular, for:
struct X {};
namespace N {
struct Y { friend struct X; };
X x;
}
... we need to not inject `X` into `N`, or the lookup for `N::x`'s type will find the wrong struct.
Perhaps we should remove this hack (for `MicrosoftExt`) now that we have a more faithful hack (for `MSVCCompat`)? It's not a conforming extension. That is, replace this with just
New->setObjectOfFriendDecl(getLangOpts().MSVCCompat);
http://reviews.llvm.org/D4443
More information about the cfe-commits
mailing list