r186804 - PR16288: A template is only missing a default template argument if it provides
Richard Smith
richard-llvm at metafoo.co.uk
Sun Jul 21 20:31:14 PDT 2013
Author: rsmith
Date: Sun Jul 21 22:31:14 2013
New Revision: 186804
URL: http://llvm.org/viewvc/llvm-project?rev=186804&view=rev
Log:
PR16288: A template is only missing a default template argument if it provides
any default template arguments, not if it inherits some.
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/default-arguments.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=186804&r1=186803&r2=186804&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sun Jul 21 22:31:14 2013
@@ -1319,7 +1319,6 @@ bool Sema::CheckTemplateParameterList(Te
} 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(Te
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(Te
} 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(Te
} 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(
Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=186804&r1=186803&r2=186804&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Sun Jul 21 22:31:14 2013
@@ -136,3 +136,14 @@ namespace PR9643 {
vector<int, allocator<int> > v = initializer<vector>(5);
}
}
+
+namespace PR16288 {
+ template<typename X>
+ struct S {
+ template<typename T = int, typename U> // expected-warning {{C++11}}
+ void f();
+ };
+ template<typename X>
+ template<typename T, typename U>
+ void S<X>::f() {}
+}
More information about the cfe-commits
mailing list