[cfe-commits] r80412 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/using-decl-templates.cpp

Anders Carlsson andersca at mac.com
Fri Aug 28 17:56:39 PDT 2009


Author: andersca
Date: Fri Aug 28 19:56:38 2009
New Revision: 80412

URL: http://llvm.org/viewvc/llvm-project?rev=80412&view=rev
Log:
Add another check for UnresolvedUsingDecl.

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

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 28 19:56:38 2009
@@ -2345,6 +2345,10 @@
   }
 }
 
+static bool isUsingDecl(Decl *D) {
+  return isa<UsingDecl>(D) || isa<UnresolvedUsingDecl>(D);
+}
+
 NamedDecl* 
 Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
                               QualType R, DeclaratorInfo *DInfo,
@@ -2695,7 +2699,7 @@
       Diag(NewFD->getLocation(), diag::err_out_of_line_declaration)
         << D.getCXXScopeSpec().getRange();
       NewFD->setInvalidDecl();
-    } else if (!Redeclaration && (!PrevDecl || !isa<UsingDecl>(PrevDecl))) {
+    } else if (!Redeclaration && (!PrevDecl || !isUsingDecl(PrevDecl))) {
       // The user tried to provide an out-of-line definition for a
       // function that is a member of a class or namespace, but there
       // was no such member function declared (C++ [class.mfct]p2, 
@@ -2896,10 +2900,9 @@
       }
     }
 
-    if (PrevDecl && 
+    if (PrevDecl &&
         (!AllowOverloadingOfFunction(PrevDecl, Context) || 
-         !IsOverload(NewFD, PrevDecl, MatchedDecl)) &&
-        !isa<UsingDecl>(PrevDecl) && !isa<UnresolvedUsingDecl>(PrevDecl)) {
+         !IsOverload(NewFD, PrevDecl, MatchedDecl)) && !isUsingDecl(PrevDecl)) {
       Redeclaration = true;
       Decl *OldDecl = PrevDecl;
 

Modified: cfe/trunk/test/SemaCXX/using-decl-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-templates.cpp?rev=80412&r1=80411&r2=80412&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/using-decl-templates.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-templates.cpp Fri Aug 28 19:56:38 2009
@@ -20,3 +20,11 @@
   
   void f() { };
 };
+
+template <typename T> struct D : A<T> {
+  using A<T>::f;
+  
+  void f();
+};
+
+template<typename T> void D<T>::f() { }





More information about the cfe-commits mailing list