]> granicus.if.org Git - clang/commitdiff
Add another check for UnresolvedUsingDecl.
authorAnders Carlsson <andersca@mac.com>
Sat, 29 Aug 2009 00:56:38 +0000 (00:56 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 29 Aug 2009 00:56:38 +0000 (00:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80412 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/using-decl-templates.cpp

index d1bb6fb453e592ab2b266560b650e7fcdd19b516..3eece142e9b9ce50cbb69e07d05b1cff733f92d3 100644 (file)
@@ -2345,6 +2345,10 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
   }
 }
 
+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 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
       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 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
       }
     }
 
-    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;
 
index b7cc69ae52164a650154166e78de232d94260d8c..42442e28606593b8a5b660ecd9fdaa7349f25c71 100644 (file)
@@ -20,3 +20,11 @@ template<typename T> struct C : A<T> {
   
   void f() { };
 };
+
+template <typename T> struct D : A<T> {
+  using A<T>::f;
+  
+  void f();
+};
+
+template<typename T> void D<T>::f() { }