diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-04 22:45:55 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-04 22:45:55 +0000 |
commit | cb710a4df50b79659399f0722ea29e90251ea834 (patch) | |
tree | b7ccdc0a0588be2e9afd9768560f0aaf6ccd04a0 /lib/Sema/SemaDecl.cpp | |
parent | 7ec1873d694cf870264694d2b61219a03492bc30 (diff) |
Diagnose destructor templates. Fixes PR7904.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127042 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 10d92029f8..e6c459504e 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3755,7 +3755,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // determine whether we have a template or a template specialization. bool Invalid = false; if (TemplateParameterList *TemplateParams - = MatchTemplateParametersToScopeSpecifier( + = MatchTemplateParametersToScopeSpecifier( D.getDeclSpec().getSourceRange().getBegin(), D.getCXXScopeSpec(), TemplateParamLists.get(), @@ -3773,6 +3773,13 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (CheckTemplateDeclScope(S, TemplateParams)) return 0; + // A destructor cannot be a template. + if (Name.getNameKind() == DeclarationName::CXXDestructorName) { + Diag(NewFD->getLocation(), diag::err_destructor_template); + return 0; + } + + FunctionTemplate = FunctionTemplateDecl::Create(Context, DC, NewFD->getLocation(), Name, TemplateParams, |