diff options
| author | Douglas Gregor <dgregor@apple.com> | 2013-06-27 20:42:30 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2013-06-27 20:42:30 +0000 |
| commit | f83b4ea8b6482630238645c241504b3694c283e8 (patch) | |
| tree | 7a5ffe4d3bd2d1e65337d2cd2246e92c2c707c80 /clang | |
| parent | ccaf3321f1caaaeb8672758753245a521aa77f63 (diff) | |
| download | bcm5719-llvm-f83b4ea8b6482630238645c241504b3694c283e8.tar.gz bcm5719-llvm-f83b4ea8b6482630238645c241504b3694c283e8.zip | |
Under -fms-extensions, only inject a friend tag name when we didn't see a tag with that name in an enclosing scope.
r177473 made us correctly consider only those declarations in the
enclosing namespace scope when looking for a friend declaration. Under
ms-extensions mode, where we do some level of friend injection, this
meant that we were introducing a new tag type into a different scope
than what Microsoft actually does. Address this by only doing the
friend injection when we didn't see any tag with that name in any
outer scope. Fixes <rdar://problem/14250378>.
llvm-svn: 185100
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaCXX/MicrosoftExtensions.cpp | 20 |
2 files changed, 27 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 08e8cb798ac..a87cf61ccfe 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9614,7 +9614,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, Redecl = NotForRedeclaration; LookupResult Previous(*this, Name, NameLoc, LookupTagName, Redecl); - + bool FriendSawTagOutsideEnclosingNamespace = false; if (Name && SS.isNotEmpty()) { // We have a nested-name tag ('struct foo::bar'). @@ -9707,8 +9707,11 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, while (F.hasNext()) { NamedDecl *ND = F.next(); DeclContext *DC = ND->getDeclContext()->getRedeclContext(); - if (DC->isFileContext() && !EnclosingNS->Encloses(ND->getDeclContext())) + if (DC->isFileContext() && + !EnclosingNS->Encloses(ND->getDeclContext())) { F.erase(); + FriendSawTagOutsideEnclosingNamespace = true; + } } F.done(); } @@ -10208,7 +10211,8 @@ CreateNewDecl: // the tag name visible. if (TUK == TUK_Friend) New->setObjectOfFriendDecl(/* PreviouslyDeclared = */ !Previous.empty() || - getLangOpts().MicrosoftExt); + (!FriendSawTagOutsideEnclosingNamespace && + getLangOpts().MicrosoftExt)); // Set the access specifier. if (!Invalid && SearchDC->isRecord()) diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp index e82c47eb586..723beb4efca 100644 --- a/clang/test/SemaCXX/MicrosoftExtensions.cpp +++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp @@ -365,3 +365,23 @@ void SP11::UseV() { struct StructWithUnnamedMember { __declspec(property(get=GetV)) int : 10; // expected-error {{anonymous property is not supported}} }; + +namespace rdar14250378 { + class Bar {}; + + namespace NyNamespace { + class Foo { + public: + Bar* EnsureBar(); + }; + + class Baz : public Foo { + public: + friend class Bar; + }; + + Bar* Foo::EnsureBar() { + return 0; + } + } +} |

