From: Anders Carlsson Date: Sat, 29 Aug 2009 00:56:38 +0000 (+0000) Subject: Add another check for UnresolvedUsingDecl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=203cb71998a39a9d01a29db135454a9e7f402235;p=clang Add another check for UnresolvedUsingDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80412 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d1bb6fb453..3eece142e9 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2345,6 +2345,10 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl, } } +static bool isUsingDecl(Decl *D) { + return isa(D) || isa(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(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(PrevDecl) && !isa(PrevDecl)) { + !IsOverload(NewFD, PrevDecl, MatchedDecl)) && !isUsingDecl(PrevDecl)) { Redeclaration = true; Decl *OldDecl = PrevDecl; diff --git a/test/SemaCXX/using-decl-templates.cpp b/test/SemaCXX/using-decl-templates.cpp index b7cc69ae52..42442e2860 100644 --- a/test/SemaCXX/using-decl-templates.cpp +++ b/test/SemaCXX/using-decl-templates.cpp @@ -20,3 +20,11 @@ template struct C : A { void f() { }; }; + +template struct D : A { + using A::f; + + void f(); +}; + +template void D::f() { }