[cfe-commits] r112383 - in /cfe/trunk: include/clang/Sema/Lookup.h lib/Sema/SemaTemplate.cpp test/SemaTemplate/temp.cpp

John McCall rjmccall at apple.com
Sat Aug 28 13:17:00 PDT 2010


Author: rjmccall
Date: Sat Aug 28 15:17:00 2010
New Revision: 112383

URL: http://llvm.org/viewvc/llvm-project?rev=112383&view=rev
Log:
If filtering a lookup result leaves it ambiguous, keep the ambiguity     
kind.  Fixes PR7252.


Modified:
    cfe/trunk/include/clang/Sema/Lookup.h
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/temp.cpp

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=112383&r1=112382&r2=112383&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Sat Aug 28 15:17:00 2010
@@ -366,10 +366,15 @@
       if (ResultKind != NotFoundInCurrentInstantiation)
         ResultKind = NotFound;
     } else {
+      AmbiguityKind SavedAK = Ambiguity;
       ResultKind = Found;
       resolveKind();
-      
-      if (Paths && (ResultKind != Ambiguous)) {
+
+      // If we didn't make the lookup unambiguous, restore the old
+      // ambiguity kind.
+      if (ResultKind == Ambiguous) {
+        Ambiguity = SavedAK;
+      } else if (Paths) {
         deletePaths(Paths);
         Paths = 0;
       }

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=112383&r1=112382&r2=112383&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sat Aug 28 15:17:00 2010
@@ -141,8 +141,13 @@
                  LookupOrdinaryName);
   LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
                      MemberOfUnknownSpecialization);
-  if (R.empty() || R.isAmbiguous()) {
+  if (R.empty()) return TNK_Non_template;
+  if (R.isAmbiguous()) {
+    // Suppress diagnostics;  we'll redo this lookup later.
     R.suppressDiagnostics();
+
+    // FIXME: we might have ambiguous templates, in which case we
+    // should at least parse them properly!
     return TNK_Non_template;
   }
 

Modified: cfe/trunk/test/SemaTemplate/temp.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp.cpp?rev=112383&r1=112382&r2=112383&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp.cpp Sat Aug 28 15:17:00 2010
@@ -1,5 +1,19 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 
-// p3
-template<typename T> int foo(T), bar(T, T); // expected-error{{single entity}}
+namespace test0 {
+  // p3
+  template<typename T> int foo(T), bar(T, T); // expected-error{{single entity}}
+}
+
+// PR7252
+namespace test1 {
+  namespace A { template<typename T> struct Base { typedef T t; }; } // expected-note {{member found}}
+  namespace B { template<typename T> struct Base { typedef T t; }; } // expected-note {{member found}}
+
+  template<typename T> struct Derived : A::Base<char>, B::Base<int> {
+    // FIXME: the syntax error here is unfortunate
+    typename Derived::Base<float>::t x; // expected-error {{found in multiple base classes of different types}} \
+                                        // expected-error {{expected member name or ';'}}
+  };
+}





More information about the cfe-commits mailing list