On Thu, May 19, 2016 at 12:55:18PM -0400, Jason Merrill wrote:
> Well, constants aren't declarations.  Why are we calling dump_decl here?

Eh, not sure what I was thinking...

We call dump_decl because unify_template_argument_mismatch has %qD:
    inform (input_location,
            "  template argument %qE does not match %qD", arg, parm);
so I suspect we want to print expression ever for PARM:

Untested, but I think it should test fine.  Ok if testing passes?

2016-05-19  Marek Polacek  <pola...@redhat.com>

        PR c++/71075
        * pt.c (unify_template_argument_mismatch): Use %qE instead of %qD.

        * g++.dg/diagnostic/pr71075.C: New test.

diff --git gcc/cp/pt.c gcc/cp/pt.c
index fde3091..ea7778d 100644
--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -6165,7 +6165,7 @@ unify_template_argument_mismatch (bool explain_p, tree 
parm, tree arg)
 {
   if (explain_p)
     inform (input_location,
-           "  template argument %qE does not match %qD", arg, parm);
+           "  template argument %qE does not match %qE", arg, parm);
   return 1;
 }
 
diff --git gcc/testsuite/g++.dg/diagnostic/pr71075.C 
gcc/testsuite/g++.dg/diagnostic/pr71075.C
index e69de29..6bb1e68 100644
--- gcc/testsuite/g++.dg/diagnostic/pr71075.C
+++ gcc/testsuite/g++.dg/diagnostic/pr71075.C
@@ -0,0 +1,8 @@
+// PR c++/71075
+
+template<typename T, int I> struct A {};
+template<typename T> void foo(A<T,1>) {}
+int main() {
+  foo(A<int,2>()); // { dg-error "no matching" }
+// { dg-message "template argument .2. does not match .1." "" { target *-*-* } 
6 }
+}

        Marek

Reply via email to