]> granicus.if.org Git - clang/commitdiff
PR16288: A template is only missing a default template argument if it provides
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 22 Jul 2013 03:31:14 +0000 (03:31 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 22 Jul 2013 03:31:14 +0000 (03:31 +0000)
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

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/default-arguments.cpp

index decac1dfc57b19c4f0a588d3172caf22a7adc3e4..af0eb08f20355298664272f2544153e0723d4016 100644 (file)
@@ -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(
index 6391369aa5c470ece2245470d6f5dd69d609607f..aca5c972adbc91cd369e1bd3ea6fbe22d9a13b16 100644 (file)
@@ -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() {}
+}