зеркало из https://github.com/microsoft/clang-1.git
When checking for a prior declaration of the name of a namespace, skip
any names that aren't in the appropriate identifier namespaces. Fixes an embarrassing bug where we give a redefinition error due to an Objective-C category (<rdar://problem/9388207>). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131036 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
31e7f225fa
Коммит
010157f9db
|
@ -3730,10 +3730,21 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
|
|||
// treated as an original-namespace-name.
|
||||
//
|
||||
// Since namespace names are unique in their scope, and we don't
|
||||
// look through using directives, just
|
||||
DeclContext::lookup_result R = CurContext->getRedeclContext()->lookup(II);
|
||||
NamedDecl *PrevDecl = R.first == R.second? 0 : *R.first;
|
||||
|
||||
// look through using directives, just look for any ordinary names.
|
||||
|
||||
const unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Member |
|
||||
Decl::IDNS_Type | Decl::IDNS_Using | Decl::IDNS_Tag |
|
||||
Decl::IDNS_Namespace;
|
||||
NamedDecl *PrevDecl = 0;
|
||||
for (DeclContext::lookup_result R
|
||||
= CurContext->getRedeclContext()->lookup(II);
|
||||
R.first != R.second; ++R.first) {
|
||||
if ((*R.first)->getIdentifierNamespace() & IDNS) {
|
||||
PrevDecl = *R.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NamespaceDecl *OrigNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl)) {
|
||||
// This is an extended namespace definition.
|
||||
if (Namespc->isInline() != OrigNS->isInline()) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
// <rdar://problem/9388207>
|
||||
@interface A
|
||||
@end
|
||||
|
||||
@interface A(N)
|
||||
@end
|
||||
|
||||
@protocol M
|
||||
@end
|
||||
|
||||
namespace N { }
|
||||
namespace M { }
|
Загрузка…
Ссылка в новой задаче