Check that the alias points to a valid namespace.

llvm-svn: 67925
This commit is contained in:
Anders Carlsson 2009-03-28 06:42:02 +00:00
parent ae1aa43617
commit ac2c96528f
2 changed files with 20 additions and 0 deletions

View File

@ -1627,6 +1627,7 @@ Sema::DeclTy *Sema::ActOnUsingDirective(Scope *S,
// Lookup namespace name.
LookupResult R = LookupParsedName(S, &SS, NamespcName,
LookupNamespaceName, false);
// FIXME: Can the result of a namespace lookup ever be ambiguous?
if (R.isAmbiguous()) {
DiagnoseAmbiguousLookup(R, NamespcName, IdentLoc);
return 0;
@ -1693,6 +1694,20 @@ Sema::DeclTy *Sema::ActOnNamespaceAliasDef(Scope *S,
return 0;
}
// Lookup the namespace name.
LookupResult R = LookupParsedName(S, &SS, NamespaceName,
LookupNamespaceName, false);
// FIXME: Can the result of a namespace lookup ever be ambiguous?
if (R.isAmbiguous()) {
DiagnoseAmbiguousLookup(R, NamespaceName, NamespaceLoc);
return 0;
}
if (!R) {
Diag(NamespaceLoc, diag::err_expected_namespace_name) << SS.getRange();
return 0;
}
return 0;
}

View File

@ -9,3 +9,8 @@ namespace B = N; // expected-error {{redefinition of 'B' as different kind of sy
namespace C { } // expected-note {{previous definition is here}}
namespace C = N; // expected-error {{redefinition of 'C'}}
int i;
namespace D = i; // expected-error {{expected namespace name}}
namespace E = N::Foo; // expected-error {{expected namespace name}}