[cfe-commits] r67925 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/namespace-alias.cpp

Anders Carlsson andersca at mac.com
Fri Mar 27 23:42:02 PDT 2009


Author: andersca
Date: Sat Mar 28 01:42:02 2009
New Revision: 67925

URL: http://llvm.org/viewvc/llvm-project?rev=67925&view=rev
Log:
Check that the alias points to a valid namespace.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/namespace-alias.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=67925&r1=67924&r2=67925&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Mar 28 01:42:02 2009
@@ -1627,6 +1627,7 @@
   // 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 @@
     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;
 }
 

Modified: cfe/trunk/test/SemaCXX/namespace-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/namespace-alias.cpp?rev=67925&r1=67924&r2=67925&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/namespace-alias.cpp (original)
+++ cfe/trunk/test/SemaCXX/namespace-alias.cpp Sat Mar 28 01:42:02 2009
@@ -9,3 +9,8 @@
 
 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}}





More information about the cfe-commits mailing list