PR c++/37766
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Oct 2009 21:04:27 +0000 (21:04 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Oct 2009 21:04:27 +0000 (21:04 +0000)
* pt.c (type_unification_real): Call convert_template_argument
for function default template arguments.
(check_default_tmpl_args): Suggest -std=c++0x when function default
template args seen in C++98 mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152685 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C [new file with mode: 0644]

index d2a46b2..07dc96a 100644 (file)
@@ -1,3 +1,11 @@
+2009-10-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37766
+       * pt.c (type_unification_real): Call convert_template_argument
+       for function default template arguments.
+       (check_default_tmpl_args): Suggest -std=c++0x when function default
+       template args seen in C++98 mode.
+
 2009-10-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/37204
index 148adab..084ad1c 100644 (file)
@@ -4025,7 +4025,8 @@ check_default_tmpl_args (tree decl, tree parms, int is_primary,
   else if (is_friend_decl)
     msg = "default template arguments may not be used in function template friend declarations";
   else if (TREE_CODE (decl) == FUNCTION_DECL && (cxx_dialect == cxx98))
-    msg = "default template arguments may not be used in function templates";
+    msg = ("default template arguments may not be used in function templates "
+          "without -std=c++0x or -std=gnu++0x");
   else if (is_partial)
     msg = "default template arguments may not be used in partial specializations";
   else
@@ -13178,9 +13179,11 @@ type_unification_real (tree tparms,
             to explicitly check cxx_dialect here.  */
           if (TREE_PURPOSE (TREE_VEC_ELT (tparms, i)))
             {
-              tree arg = tsubst_template_arg
-                               (TREE_PURPOSE (TREE_VEC_ELT (tparms, i)),
-                                targs, tf_none, NULL_TREE);
+             tree parm = TREE_VALUE (TREE_VEC_ELT (tparms, i));
+             tree arg = TREE_PURPOSE (TREE_VEC_ELT (tparms, i));
+              arg = tsubst_template_arg (arg, targs, tf_none, NULL_TREE);
+             arg = convert_template_argument (parm, arg, targs, tf_none,
+                                              i, NULL_TREE);
               if (arg == error_mark_node)
                 return 1;
               else
index 5e5f39c..e9ca25b 100644 (file)
@@ -1,3 +1,8 @@
+2009-10-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37766
+       * g++.dg/cpp0x/fntmpdefarg1.C: New.
+
 2009-10-12  Janis Johnson  <janis187@us.ibm.com>
 
        * gcc.dg/lto/20090914-2.c: Fix typos in test directives.
diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C
new file mode 100644 (file)
index 0000000..25192ad
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/37766
+// { dg-options -std=c++0x }
+
+int a = 1;
+template<int& b = a> void f() {
+  f<>();
+}