From: Richard Smith Date: Mon, 22 Jul 2013 03:31:14 +0000 (+0000) Subject: PR16288: A template is only missing a default template argument if it provides X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03c55be552d224c787c3dd2e981b47a23b05cc2d;p=clang PR16288: A template is only missing a default template argument if it provides any default template arguments, not if it inherits some. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186804 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index decac1dfc5..af0eb08f20 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1319,7 +1319,6 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, } else if (OldTypeParm && OldTypeParm->hasDefaultArgument()) { // Merge the default argument from the old declaration to the // new declaration. - SawDefaultArgument = true; NewTypeParm->setDefaultArgument(OldTypeParm->getDefaultArgumentInfo(), true); PreviousDefaultArgLoc = OldTypeParm->getDefaultArgumentLoc(); @@ -1356,7 +1355,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, if (!NewNonTypeParm->isPackExpansion()) SawParameterPack = true; } else if (OldNonTypeParm && OldNonTypeParm->hasDefaultArgument() && - NewNonTypeParm->hasDefaultArgument()) { + NewNonTypeParm->hasDefaultArgument()) { OldDefaultLoc = OldNonTypeParm->getDefaultArgumentLoc(); NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc(); SawDefaultArgument = true; @@ -1365,7 +1364,6 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, } else if (OldNonTypeParm && OldNonTypeParm->hasDefaultArgument()) { // Merge the default argument from the old declaration to the // new declaration. - SawDefaultArgument = true; // FIXME: We need to create a new kind of "default argument" // expression that points to a previous non-type template // parameter. @@ -1413,7 +1411,6 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, } else if (OldTemplateParm && OldTemplateParm->hasDefaultArgument()) { // Merge the default argument from the old declaration to the // new declaration. - SawDefaultArgument = true; // FIXME: We need to create a new kind of "default argument" expression // that points to a previous template template parameter. NewTemplateParm->setDefaultArgument( diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index 6391369aa5..aca5c972ad 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.cpp @@ -136,3 +136,14 @@ namespace PR9643 { vector > v = initializer(5); } } + +namespace PR16288 { + template + struct S { + template // expected-warning {{C++11}} + void f(); + }; + template + template + void S::f() {} +}