[cfe-commits] r68952 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/using-directive.cpp

Douglas Gregor dgregor at apple.com
Mon Apr 13 08:14:40 PDT 2009


Author: dgregor
Date: Mon Apr 13 10:14:38 2009
New Revision: 68952

URL: http://llvm.org/viewvc/llvm-project?rev=68952&view=rev
Log:
Make the selection of type declarations in Sema::getTypeName
deterministic when faced with an ambiguity. This eliminates the
annoying test/SemaCXX/using-directive.cpp failure.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/using-directive.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 13 10:14:38 2009
@@ -85,8 +85,10 @@
     for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end();
          Res != ResEnd; ++Res) {
       if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) {
-        IIDecl = *Res;
-        break;
+        if (!IIDecl || 
+            (*Res)->getLocation().getRawEncoding() < 
+              IIDecl->getLocation().getRawEncoding())
+          IIDecl = *Res;
       }
     }
 

Modified: cfe/trunk/test/SemaCXX/using-directive.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-directive.cpp?rev=68952&r1=68951&r2=68952&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/using-directive.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-directive.cpp Mon Apr 13 10:14:38 2009
@@ -1,5 +1,4 @@
 // RUN: clang-cc -fsyntax-only -verify %s
-// XFAIL
 
 namespace A {
   short i; // expected-note 2{{candidate found by name lookup is 'A::i'}}
@@ -95,8 +94,7 @@
 }
 
 namespace TwoTag {
-  struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}} \
-  // expected-note{{forward declaration}}
+  struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}}
 }
 
 namespace FuncHidesTagAmbiguity {
@@ -105,7 +103,6 @@
   using namespace TwoTag;
 
   void test() {
-    (void)X(); // expected-error{{reference to 'X' is ambiguous}} \
-      // FIXME: expected-error{{invalid use of incomplete type}}
+    (void)X(); // expected-error{{reference to 'X' is ambiguous}}
   }
 }





More information about the cfe-commits mailing list