re PR c++/17344 (completely wacky error with matching template template classes and...
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Sun, 14 Nov 2004 10:57:00 +0000 (10:57 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Sun, 14 Nov 2004 10:57:00 +0000 (10:57 +0000)
PR c++/17344
* pt.c (coerce_template_parms): Only emit error message about
invalid template argument when TF_ERROR.

* g++.dg/template/defarg5.C: New test.

From-SVN: r90615

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

index fe51d5b..9ca645a 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-14  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/17344
+       * pt.c (coerce_template_parms): Only emit error message about
+       invalid template argument when TF_ERROR.
+
 2004-11-12  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/18389
index 54c9979..34fd27b 100644 (file)
@@ -4007,7 +4007,10 @@ coerce_template_parms (tree parms,
       
       gcc_assert (arg);
       if (arg == error_mark_node)
-       error ("template argument %d is invalid", i + 1);
+       {
+         if (complain & tf_error)
+           error ("template argument %d is invalid", i + 1);
+       }
       else 
        arg = convert_template_argument (TREE_VALUE (parm), 
                                         arg, new_args, complain, i,
index dbedb3e..ef48eaf 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-14  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/17344
+       * g++.dg/template/defarg5.C: New test.
+
 2004-11-13  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * g++.dg/parse/cast1.C: Run only on ILP32.
diff --git a/gcc/testsuite/g++.dg/template/defarg5.C b/gcc/testsuite/g++.dg/template/defarg5.C
new file mode 100644 (file)
index 0000000..b436374
--- /dev/null
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+// Origin: Ivan Godard <igodard@pacbell.net>
+//        Wolfgang Bangerth <bangerth@dealii.org>
+
+// PR c++/17344: Substitution failure is not an error
+// for default template argument
+
+template <class> struct intTraits; 
+template<> struct intTraits<int> { 
+    static const int i = 0; 
+}; 
+template<typename E, E i = intTraits<E>::i> struct A {}; 
+struct S { 
+    template <template <typename> class X> S(X<void>); 
+}; 
+int bar(S); 
+int bar(A<int,0>); 
+A<int> bed; 
+int i = bar(bed);