// Find the previous declaration and check that we can redeclare it.
NamespaceAliasDecl *Prev = nullptr;
- if (NamedDecl *PrevDecl = PrevR.getAsSingle<NamedDecl>()) {
- if (NamespaceAliasDecl *AD =
- dyn_cast<NamespaceAliasDecl>(PrevR.getRepresentativeDecl())) {
+ if (PrevR.isSingleResult()) {
+ NamedDecl *PrevDecl = PrevR.getRepresentativeDecl();
+ if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(PrevDecl)) {
// We already have an alias with the same name that points to the same
// namespace; check that it matches.
if (AD->getNamespace()->Equals(getNamespaceDecl(ND))) {
return nullptr;
}
} else if (isVisible(PrevDecl)) {
- unsigned DiagID = isa<NamespaceDecl>(PrevDecl)
+ unsigned DiagID = isa<NamespaceDecl>(PrevDecl->getUnderlyingDecl())
? diag::err_redefinition
: diag::err_redefinition_different_kind;
Diag(AliasLoc, DiagID) << Alias;
int x2 = X::x; // ok, unambiguous
int y2 = Y::y; // ok, unambiguous
}
+
+namespace RedeclOfNonNamespace {
+ int a; // expected-note {{previous}}
+ namespace X { int b; }
+ using X::b; // expected-note {{previous}}
+ namespace c {} // expected-note {{previous}}
+
+ namespace a = X; // expected-error {{different kind}}
+ namespace b = X; // expected-error {{different kind}}
+ namespace c = X; // expected-error-re {{redefinition of 'c'{{$}}}}
+}