]> granicus.if.org Git - clang/commitdiff
Avoid duplicated diagnostic when lookup for a nested-name-specifier fails due to...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 12 Nov 2015 22:40:09 +0000 (22:40 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 12 Nov 2015 22:40:09 +0000 (22:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaCXXScopeSpec.cpp
test/CXX/temp/temp.res/temp.local/p3.cpp
test/Modules/no-linkage.cpp

index 9e146ed3a6427b006767102408ce8951b0fec7cb..68a1d7368e2e6422402ba5ec7290f4141e27e726 100644 (file)
@@ -533,6 +533,9 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
     LookupName(Found, S);
   }
 
+  if (Found.isAmbiguous())
+    return true;
+
   // If we performed lookup into a dependent context and did not find anything,
   // that's fine: just build a dependent nested-name-specifier.
   if (Found.empty() && isDependent &&
@@ -551,8 +554,6 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
     return false;
   }
 
-  // FIXME: Deal with ambiguities cleanly.
-
   if (Found.empty() && !ErrorRecoveryLookup) {
     // If identifier is not found as class-name-or-namespace-name, but is found
     // as other entity, don't look for typos.
@@ -562,6 +563,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
     else if (S && !isDependent)
       LookupName(R, S);
     if (!R.empty()) {
+      // Don't diagnose problems with this speculative lookup.
+      R.suppressDiagnostics();
       // The identifier is found in ordinary lookup. If correction to colon is
       // allowed, suggest replacement to ':'.
       if (IsCorrectedToColon) {
index d5e37866059648ea843cced475b77954ee1a10ab..63c40fb5769072376103c216bf1f07e824ec45d0 100644 (file)
@@ -14,8 +14,7 @@ template <class T> struct Derived: Base<int>, Base<char> {
     t->Derived::Base<T>::f();
     t->Base<T>::f();
     t->Base::f(); // expected-error{{member 'Base' found in multiple base classes of different types}} \
-    // expected-error{{no member named 'f' in 'X0'}} \
-    // expected-error{{'Base' is not a class, namespace, or enumeration}}
+    // expected-error{{no member named 'f' in 'X0'}}
   }
 };
 
index 508464e8dbe0d42086f341ef15b14683889c1ee6..0cc808b6331c6a9989f575523e84d0d35e70987a 100644 (file)
@@ -28,7 +28,7 @@ void use_things() {
 
 void use_things_again() {
   use(Typedef().n); // expected-error {{ambiguous}}
-  use(NS::n); // expected-error {{ambiguous}} expected-error{{'NS' is not a class, namespace, or enumeration}}
+  use(NS::n); // expected-error {{ambiguous}}
   use(AliasDecl); // expected-error {{ambiguous}}
   use(Enumerator); // expected-error {{ambiguous}}
   use(UsingDecl); // expected-error {{ambiguous}}