aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDeclCXX.cpp15
-rw-r--r--test/SemaCXX/namespace-alias.cpp5
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 4c8437deee..7f8a69e5f3 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -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;
}
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 745893082b..7d46d08678 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -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}}