diff options
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 | ||||
| -rw-r--r-- | clang/test/SemaCXX/using-decl-templates.cpp | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d1bb6fb453e..3eece142e9b 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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; diff --git a/clang/test/SemaCXX/using-decl-templates.cpp b/clang/test/SemaCXX/using-decl-templates.cpp index b7cc69ae521..42442e28606 100644 --- a/clang/test/SemaCXX/using-decl-templates.cpp +++ b/clang/test/SemaCXX/using-decl-templates.cpp @@ -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() { } |

