diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-10-13 17:02:54 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-10-13 17:02:54 +0000 |
| commit | 62e10f0bdcaa28194f8a48892471a2fdf014528a (patch) | |
| tree | ae70c03b2d77febd7a0d9cae0aee29cbd49a5207 /clang/lib | |
| parent | 9f73552852510ea9c427797dba25689c451e40a7 (diff) | |
| download | bcm5719-llvm-62e10f0bdcaa28194f8a48892471a2fdf014528a.tar.gz bcm5719-llvm-62e10f0bdcaa28194f8a48892471a2fdf014528a.zip | |
Diagnose attempts to add default function arguments to a
specialization. This completes C++ [temp.expl.spec]!
llvm-svn: 83980
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 519694aea84..646ac75dd3f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -296,6 +296,22 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) { << NewParam->getDefaultArgRange(); Diag(Old->getLocation(), diag::note_template_prev_declaration) << false; + } else if (New->getTemplateSpecializationKind() + != TSK_ImplicitInstantiation && + New->getTemplateSpecializationKind() != TSK_Undeclared) { + // C++ [temp.expr.spec]p21: + // Default function arguments shall not be specified in a declaration + // or a definition for one of the following explicit specializations: + // - the explicit specialization of a function template; + // — the explicit specialization of a member function template; + // — the explicit specialization of a member function of a class + // template where the class template specialization to which the + // member function specialization belongs is implicitly + // instantiated. + Diag(NewParam->getLocation(), diag::err_template_spec_default_arg) + << (New->getTemplateSpecializationKind() ==TSK_ExplicitSpecialization) + << New->getDeclName() + << NewParam->getDefaultArgRange(); } else if (New->getDeclContext()->isDependentContext()) { // C++ [dcl.fct.default]p6 (DR217): // Default arguments for a member function of a class template shall |

