]> granicus.if.org Git - clang/commitdiff
Check that the alias points to a valid namespace.
authorAnders Carlsson <andersca@mac.com>
Sat, 28 Mar 2009 06:42:02 +0000 (06:42 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 28 Mar 2009 06:42:02 +0000 (06:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67925 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/namespace-alias.cpp

index 4c8437deee1de6bf25da6decd2cdbf68ee6bd305..7f8a69e5f306cd4e7fe4d9e6b9b06627deb76d96 100644 (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;
 }
 
index 745893082bbaaf8ae9f846b2f815ea48310be02c..7d46d08678a3a7038e6f84104fb6cc2600f13c34 100644 (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}}